Search Results

Search found 1672 results on 67 pages for 'nhibernate'.

Page 29/67 | < Previous Page | 25 26 27 28 29 30 31 32 33 34 35 36  | Next Page >

  • Anyone using ASP.NET MembershipProvider with Nhibernate?

    - by JLago
    Hi, I'm trying to implement Membership controls in a mvc 2 application and i'm having trouble dealing with the MembershipUser class. I have my own data store (in Postgresql) and I'm using Nhibernate to deal with it from C#. The thing is, I have my own user class, but I can't use it with any provider I found that implements Membership, because all the functions return the predefined MembershipUser class and cannot return my own. I'm losing my mind here, is there any way i can work with this, or should I implement everything myself? thanks in advance!

    Read the article

  • Deleting a Collection with NHibernate Using the Criteria API

    - by lomaxx
    I think I know what the answer to this question is probably going to be, but I thought I'd go ahead and ask it anyway. It appears that within NHibernate if I do something like this: IList<Customer> customers = Session.CreateCriteria(typeof(Customer)) .Add(Restrictions.Eq("Name", "Steve") .List<Customer>(); And I want to then delete that list of customers. From what I can tell the only way to do it is like this: foreach(var customer in customers) { Session.Delete(customer); } But what I'm wondering is if there's any way I can just go: Session.Delete(customers); And delete the entire collection with a single call?

    Read the article

  • nHibernate Linq Projection

    - by Craig
    I am using the version 1.0 release of Linq for nHibernate. When I run the following linq statements I receive the error not a single-length projection: Surname I can find very few references to this on the web and looking into the source it says it should never occur! ClientID is a Int type and Surname is a string. When I comment out all the string fields in the projection and just leave ClientID it runs ok, but as soon as I add surname back it errors. var context = m_ClientRepository.Linq; var result = (from client in context from address in client.Addresses from contact in client.Contacts where client.Surname.StartsWith(surname) && client.GivenName.StartsWith(givenName) && contact.Value.StartsWith(phoneNumber) group client by new { client.ClientID, client.Surname, client.GivenName } into clientGroup select new ClientSearchDTO() { ClientID = clientGroup.Key.ClientID, Surname = clientGroup.Key.Surname, GivenName = clientGroup.Key.GivenName, Address = clientGroup.Max(x => x.Addresses.FirstOrDefault().Address), PhoneNumber = clientGroup.Max(x => x.Contacts.FirstOrDefault().Value) }) .Skip(Paging.FirstRecord(pageNumber)) .Take(5);

    Read the article

  • NHibernate and Composite Key References

    - by Rich
    I have a weird situation. I have three entities, Company, Employee, Plan and Participation (in retirement plan). Company PK: Company ID Plan PK: Company ID, Plan ID Employee PK: Company ID, SSN, Employee ID Participation PK: Company ID, SSN, Plan ID The problem is in linking the employee to the participation. From a DB perspective, participation should have Employee ID in the PK (it's not even in table). But it doesn't. NHibernate won't let me map the "has many" because the link expects 3 columns (since Employee PK has 3 columns), but I'd only provide 2. Any ideas on how to do this?

    Read the article

  • Fluent many-to-many: Deleting one end does not remove the entry in the relation table

    - by Kristoffer
    I have two classes (Parent, Child) that have a many-to-many relationship that only one end (Parent) knows about. My problem is that when I delete a "relation unaware" object (Child), the record in the many-to-many table is left. I want the relationship to be removed regardless of which end of it is deleted. How can I do that with Fluent NHibernate mappings, without adding a Parent property on Child? The classes: public class Parent { public Guid Id { get; set; } public IList<Child> Children { get; set; } } public class Child { public Guid Id { get; set; } // Don't want the property below: // public Parent Parent { get; set; } }

    Read the article

  • Reverse Expression.Like criterion

    - by Joel Potter
    How should I go about writing a backwards like statement using NHibernate criteria? WHERE 'somestring' LIKE [Property] + '%' Sub Question: Can you access the abstract root alias in a SQLCriterion expression? This is somewhat achievable using the SQLCriterion expression Expression.Sql("? like {alias}.[Property] + '.%'", value, NHibernateUtil.String); However, in the case of class inheritance, {alias} is replaced with the incorrect alias for the column. Example (these classes are stored in separate tables): public abstract class Parent { public virtual string Property { get; set; } } public class Child : Parent { } The above query executed with Child as the root type will replace {alias} with the alias to the Child table rather than the Parent table. This results in an invalid column exception. I need to execute a like statement as above where the property exists on the parent table rather than on the root type table.

    Read the article

  • How to debug Fluent nHibernate

    - by Matt Thrower
    Hi, I'm having some trouble with Fluent nHibernate. I added a column to a table and I thought I'd correctly changed the mappings and the connected data objects to correctly reflect this. However when I tried to run my application again I kept getting this error: System.Data.SqlClient.SqlException: Invalid column name 'Workflow_id'. I really couldn't see what the problem was with the changes I'd made so I reverted back to the original versions of the mapping and data object files from source control and removed the offending column from the database. But I'm still getting the same error. I'd like some advice on how to debug this. The SQL that gets reported on the error is semi-nonsensical: SELECT regions0_.Page_id as Page5_1_, regions0_.Id as Id1_, regions0_.Id as Id27_0_, regions0_.RegionId as RegionId27_0_, regions0_.RegionTemplate_id as RegionTe3_27_0_, regions0_.Workflow_id as Workflow4_27_0_ FROM [Region] regions0_ WHERE regions0_.Page_id=? And it won't execute as valid SQL anyway. Any ideas as to where to go from here?

    Read the article

  • Correct model for a database with a table for each user.

    - by BAH
    Kinda stuck here... I have an application with lets say 5000 rows of data per user and was wondering if it was right or wrong to do it this way: On user account creation a new table is created (UserData_[UserID]) or should I just have 1 table for userdata and have everything in there with a column for userid? The reason I am stuck at the moment is that it seems NHibernate isn't able to be mapped to dynamic table names without creating another ISessionFactory which has alot of overhead AFAIK. Any help would be greatly appreciated. Thanks.

    Read the article

  • fluent nhibernate not caching queries in asp.net mvc

    - by AWC
    I'm using a fluent nhibernate with asp.net mvc and I not seeing anything been cached when making queries against the database. I'm not currently using an L2 cache implementation. Should I see queries being cached without configuring an out of process L2 cache? Mapping are like this: Table("ApplicationCategories"); Not.LazyLoad(); Cache.ReadWrite().IncludeAll(); Id(x => x.Id); Map(x => x.Name).Not.Nullable(); Map(x => x.Description).Nullable(); Example Criteria: return session .CreateCriteria<ApplicationCategory>() .Add(Restrictions.Eq("Name", _name)) .SetCacheable(true); Everytime I make a request for an application cateogry by name it is hitting the database is this expected behaviour?

    Read the article

  • Nhibernate Bind

    - by user329983
    I have two oracle user defined types: Audit_Type – A normal object with two fields a string and a number Audit_Table_Type – A table of audit_types, (an array) I have a stored procedure that takes as a parameter an Audit_Table_Type. List<Audit_Type> table = new List<Audit_Type>(); var query = session.CreateSQLQuery("call Audit_Rows(Audit_Table_Type(:table))") .SetParameterList("table", table, NHibernateUtil.Custom(typeof(AuditTypeUDT))) This is what I did intuativly created the ICompositeType and just set in a list of them in but this gives me nothing close to what I wanted. I couldn’t figure out how to bind to a table at all. I have built the inline sql that would do this for me but it would destroy my shared pool (not using binds). So a General question how do I bind to complex/composite types using Nhibernate?

    Read the article

  • Nhibernate Complex Type binding

    - by user329983
    I have two oracle user defined types: Audit_Type – A normal object with two fields a string and a number Audit_Table_Type – A table of audit_types, (an array) I have a stored procedure that takes as a parameter an Audit_Table_Type. List<Audit_Type> table = new List<Audit_Type>(); var query = session.CreateSQLQuery("call Audit_Rows(Audit_Table_Type(:table))") .SetParameterList("table", table, NHibernateUtil.Custom(typeof(AuditTypeUDT))) This is what I did intuativly created the ICompositeType and just set in a list of them in but this gives me nothing close to what I wanted. I couldn’t figure out how to bind to a table at all. I have built the inline sql that would do this for me but it would destroy my shared pool (not using binds). So a General question how do I bind to complex/composite types using Nhibernate?

    Read the article

  • How to map an interface in nhibernate?

    - by Josh
    I'm using two class NiceCustomer & RoughCustomer which implment the interface ICustomer. The ICustomer has four properties. They are: 1) Property Id() As Integer 2) Property Name() As String 3) Property IsNiceCustomer() As Boolean 4) ReadOnly Property AddressFullText() As String I don't know how to map the interface ICustomer, to the database. I get an error like this in the inner exception. "An association refers to an unmapped class: ICustomer" I'm using Fluent and NHibernate. Any help would be greatly appreciated. Thanks in advance.

    Read the article

  • Logging NHibernate SQL queries

    - by GuestMVCAsync
    Is there a way to access the full SQL query, including the values, inside my code? I am able to log SQL queries using log4net: <logger name="NHibernate.SQL" additivity="false"> <level value="ALL"/> <appender-ref ref="NHibernateSQLFileLog"/> </logger> However, I would like to find a way to log SQL queries from the code also. This way I will log the specific SQL query that causes an exception in my try/catch statement. Right now I have to data-mine the SQLFileLog to find the query that caused the exception when an exception occurs and it is not efficient.

    Read the article

  • How do I map repeating columns in NHibernate without creating duplicate properties

    - by Ian Oakes
    Given a database that has numerous repeating columns used for auditing and versioning, what is the best way to model it using NHibernate, without having to repeat each of the columns in each of the classes in the domain model? Every table in the database repeats these same nine columns, the names and types are identical and I don't want to replicate it in the domain model. I have read the docs and I saw the section on inheritance mapping but I couldn't see how to make it work in this scenario. This seems like a common scenario because nearly every database I've work on has had the four common audit columns (CreatedBy, CreateDate, UpdatedBy, UpdateDate) in nearly every table. This database is no different except that it introduces another five columns which are common to every table.

    Read the article

  • AutoMapping Custom Collections with FluentNHibernate

    - by ScottBelchak
    I am retrofitting a very large application to use NHibernate as it's data access strategy. Everything is going well with AutoMapping. Luckily when the domain layer was built, we used a code generator. The main issue that I am running into now is that every collection is hidden behind a custom class that derives from List<. For example public class League { public OwnerList owners {get;set;} } public class OwnerList : AppList<Owner> { } public class AppList<T> : List<T> { } What kind of Convention do I have to write to get this done?

    Read the article

  • Use SQL query to populate property in nHibernate mapping file

    - by brainimus
    I have an object which contains a property that is the result of an SQL statement. How do I add the SQL statement to my nHibernate mapping file? Example Object: public class Library{ public int BookCount { get; set; } } Example Mapping File: <hibernate-mapping> <class name="Library" table="Libraries"> <property name="BookCount" type="int"> <- This is where I want the SQL query to populate the value. -> </class> </hibernate-mapping> Example SQL Query: SELECT COUNT(*) FROM BOOKS WHERE BOOKS.LIBRARY_ID = LIBRARIES.ID

    Read the article

  • Create Custom Criterion in NHibernate?

    - by vbullinger
    I'm still a bit of a n00b when it comes to NHibernate. Let's say I have the following: var myCriteria = this.Session.CreateCriteria(typeof(SomeModel)).Add(Restrictions.Eq("SomeProperty", someValue); Then, let's say I want to add criteria in a way that's reusable. Meaning, I want to make a custom criterion. I'm seeing very, very little information online on this. Specifically, I'd like to turn the following: var myCriteria = this.Session.CreateCriteria(typeof(SomeModel)) .Add(Restrictions.Eq("SomeProperty", someValue) .CreateAlias("SomeClass", "alias", JoinType.LeftOuterJoin) .Add(Restrictions.Eq("alias.SomeOtherProperty", someOtherValue)); Into the following: var myCriteria = this.Session.CreateCriteria(typeof(SomeModel)) .Add(Restrictions.Eq("SomeProperty", someValue) .Add(this.GetAliasCriterion()); Thus extracting .CreateAlias("SomeClass", "alias", JoinType.LeftOuterJoin).Add(Restrictions.Eq("alias.SomeOtherProperty", someOtherValue)); into a method. Is this possible? How does this work?

    Read the article

  • Exposing entities via a nHibernate implementation RIA Services with querystring queries

    - by illdev
    I once read a blog post and cannot find it anymore. drat! It was about a guy who setup a wcf service (I guess RIA, but could have been something else) exposing the model via IQueryable to the querystring. Sou you could say http://host/articles/123/ratings and you'd get a list (soap or json) of serialized Rating entities (the properties which had some attribute attached) which pertained to an article with id 123. All this with nHibernate / nh linq in the back and in surprisingly few lines of code. Anyone knows what I am talking about? Experiences, suggestions?

    Read the article

  • Which data framework is better for an ASP.NET MVC site - LINQ to SQL or NHibernate

    - by Paul Alexander
    We're about to embark on some ASP.NET MVC development and have been using our own entity framework for years. However we need to support more than our entity framework is capable of and so I'd like to get some opinions about using MVC with a more robust framework. We have narrowed down or choices to either NHibernate (with the Fluent APIs) or LINQ to SQL. Which framework lends itself best to MVC style development (I know SO uses LINQ to SQL)? If we want to support SQL Server, Oracle, MySQL - does that exclude LINQ to SQL?

    Read the article

  • Select n+1 problem

    - by Arnis L.
    Foo has Title. Bar references Foo. I have a collection with Bars. I need a collection with Foo.Title. If i have 10 bars in collection, i'll call db 10 times. bars.Select(x=x.Foo.Title) At the moment this (using NHibernate Linq and i don't want to drop it) retrieves Bar collection. var q = from b in Session.Linq<Bar>() where ... select b; I read what Ayende says about this. Another related question. A bit of documentation. And another related blog post. Maybe this can help? What about this? Maybe MultiQuery is what i need? :/ But i still can't 'compile' this in proper solution. How to avoid select n+1?

    Read the article

  • Fluent NHibernate CheckProperty and Dates

    - by Chris C
    I setup a NUnit test as such: new PersistenceSpecification<MyTable>(_session) .CheckProperty(c => c.ActionDate, DateTime.Now); When I run the test via NUnit I get the following error: SomeNamespace.MapTest: System.ApplicationException : Expected '2/23/2010 11:08:38 AM' but got '2/23/2010 11:08:38 AM' for Property 'ActionDate' The ActionDate field is a datetime field in a SQL 2008 database. I use Auto Mapping and declare the ActionDate as a DateTime property in C#. If I change the test to use DateTime.Today the tests pass. My question is why is the test failing with DateTime.Now? Is NHibernate losing some precision when saving the date to the database and if so how do prevent the lose? Thank you.

    Read the article

  • Insert Update using Nhibernate

    - by Pankaj
    Hello All I am inserting Product on database, My Product Model like this public class Product { public int ProductID { get; set; } public string ProductNumber { get; set; } public string Description { get; set; } public string KeyWords { get; set; } } here my ProductNumber is coming on counter table Table- Counter Field- Counter- int when product insert then its ProductNumber come from Counter table, after insert counter increase 1. In update counter not increase. How can i insert Product in such situation using Nhibernate? Thanks

    Read the article

  • Problem with nhibernate join

    - by MexicanHacker
    I'm trying to do a join like this using fluent nhibernate: Id(x => x.Id); Map(x => x.SourceSystemRecordId,"sourceSystemRecord_id"); Then Join("cat.tbl_SourceSystemRecords", SourceSystemRecords); But, it seems I don't have a way to specify the column I want to join with from the first table, in this case I need to join on SourceSystemRecordId and not on Id Is there any way I can specify this? I tried References() but that requires me to create an object for this relationship, what I need is to aggregate the columns in sourcesystem records to the ones in the main table.

    Read the article

  • Questions about nhibernate.

    - by chobo2
    Hi I have a couple questions about nhibernate. I still don't understand what contextual sessions means. I do web stuff so I just choose "web" but I really don't know what it is doing. Should I put session.BeginTransaction() in Application_BeginRequest? Should I commit everything in Application_EndRequest? Or should I commit when needed. Say I need to insert a user and then down in some code later I need to update some other table. Should I make the user and do the update then finally commit or should I wait till both are ready to be commited? Should you always have session.Rollback() in Application_EndRequest? Should I session.close() or session.dispose() or both in Application_EndRequest?

    Read the article

  • Windsor + NHibernate + ISession + MVC

    - by dbones
    Hi I am trying to get Windsor to give me an instance ISession for each request, which should be injected into all the repositories Here is my container setup container.AddFacility<FactorySupportFacility>().Register( Component.For<ISessionFactory>().Instance(NHibernateHelper.GetSessionFactory()).LifeStyle.Singleton, Component.For<ISession>().LifeStyle.Transient .UsingFactoryMethod(kernel => kernel.Resolve<ISessionFactory>().OpenSession()) ); //add to the container container.Register( Component.For<IActionInvoker>().ImplementedBy<WindsorActionInvoker>(), Component.For(typeof(IRepository<>)).ImplementedBy(typeof(NHibernateRepository<>)) ); Its based upon a StructureMap post here http://www.kevinwilliampang.com/2010/04/06/setting-up-asp-net-mvc-with-fluent-nhibernate-and-structuremap/ however, when this is run, a new Session is created for every object it is injected too. what am I missing? thanks in advanced (FYI the NHibernateHelper, sets up the config for Nhib)

    Read the article

< Previous Page | 25 26 27 28 29 30 31 32 33 34 35 36  | Next Page >