nhibernate

When must we use eager loading in NHibernate? What is it's usage?

谁说胖子不能爱 提交于 2020-01-06 11:45:14
问题 When must we use eager loading in NHibernate? What is it's usage? 回答1: One usage is when you will cache or store an object graph (in ASP.NET Cache for instance). If you don't store the whole graph, you would be missing information on a detached object. You can reattach objects of course, but that would probably be a new roundtrip to the database anyway. If you don't eager load your collections, you would need to touch every one of the to invoke the lazy fetch. In those cases, an eager fetch

When must we use eager loading in NHibernate? What is it's usage?

我怕爱的太早我们不能终老 提交于 2020-01-06 11:44:20
问题 When must we use eager loading in NHibernate? What is it's usage? 回答1: One usage is when you will cache or store an object graph (in ASP.NET Cache for instance). If you don't store the whole graph, you would be missing information on a detached object. You can reattach objects of course, but that would probably be a new roundtrip to the database anyway. If you don't eager load your collections, you would need to touch every one of the to invoke the lazy fetch. In those cases, an eager fetch

NHibernate component with a one-to-many relation from parent

这一生的挚爱 提交于 2020-01-06 09:30:09
问题 Say I have a Queue table and a Job table. In the Job table there is a foreign key column QueueId for the Queue table, i.e. Queue.Id <-- Job.QueueId Using Fluent NHibernate it is pretty straightforward to map this to a property in the Queue class, i.e. /* QueueMap */ HasMany(x => x.Jobs) .KeyColumnNames.Add("QueueId"); But assume I have a very good reason to have a class inbetween, say something like: public class Queue { public Group Group { get; set; } } public class Group { public IList<Job

NHibernate component with a one-to-many relation from parent

£可爱£侵袭症+ 提交于 2020-01-06 09:30:09
问题 Say I have a Queue table and a Job table. In the Job table there is a foreign key column QueueId for the Queue table, i.e. Queue.Id <-- Job.QueueId Using Fluent NHibernate it is pretty straightforward to map this to a property in the Queue class, i.e. /* QueueMap */ HasMany(x => x.Jobs) .KeyColumnNames.Add("QueueId"); But assume I have a very good reason to have a class inbetween, say something like: public class Queue { public Group Group { get; set; } } public class Group { public IList<Job

NHibernate failing on deferred load action

醉酒当歌 提交于 2020-01-06 08:36:06
问题 I am seeing the following error when I get the third object of the same type (in rapid succession) from the respository. The initial get succeeds but when I go back to get the details, the rest of the load happens and I see this. NHibernate.Exceptions.GenericADOException: could not load an entity I have been all over the data and there is nothing odd about the third item at all. It is perfectly normal as are all its referenced objects. The problem, however is consistent and so probably not a

How to map this Dictionary with the newest fluentNHibernate version?

社会主义新天地 提交于 2020-01-06 04:51:06
问题 i've got one more question. I upgraded to FluentNHibernate and got now a problem with my dicitionary mappings. The class i'am trying to map has the following Property IDictionary LohnParameter The mapping is as follows HasMany(x => x.LohnParameter) .ForeignKey("cat_condition_version__id") .DictionaryKey("wrd_cntry__id") .OneToMany<boLohnartEigenschaften>() .Not.Lazy() .Inverse() .Cascade.AllDeleteOrphan(); The resulting hbm.xml looks like this: <map cascade="all-delete-orphan" inverse="true"

OnPost events run before a commit

十年热恋 提交于 2020-01-06 04:31:11
问题 Say I have some standard NHibernate code like this, which writes to an SQL database: using (var session = SessionFactory.OpenSession()) { using (var tx = session.BeginTransaction()) { var customer = session.Get<Customer>(id); customer.Property1 = "new value"; customer.Property2 = "new value"; tx.Commit(); } } I am trying to create a copy table for the Customer (in a NoSQL database). Therefore when the code above runs the following event handler runs: public void OnPostUpdate(PostUpdateEvent

Migrating NHibernate 3.3 to 5, getting Method not found: System.Data.IDbCommand NHibernate.AdoNet.AbstractBatcher.get_CurrentCommand() with SqlAzure

坚强是说给别人听的谎言 提交于 2020-01-06 03:49:00
问题 I am busy migrating a project from NHibernate 3.3.3.4 to 5.1.3. I have picked up an error when committing a transaction or flushing the session. The error I am currently receiving is as follows: Method not found: 'System.Data.IDbCommand NHibernate.AdoNet.AbstractBatcher.get_CurrentCommand()'. I have looked into the NHibernate 5.1.3 code and release notes and I can see that there has been a change to the CurrentCommand property getter for the AbstractBacther class. In this major release of

Problems with an NHibernate LINQ query in loosely coupled project

北战南征 提交于 2020-01-06 03:39:06
问题 hope you can help! I've started a project in MVC 3 and set the business domain model in another assembly, the interfaces define the contract between this assembly and all projects that will use it. I'm using Ninject to inject the dependencies into the project. I've hit a brick wall at the moment with a specific LINQ query. public IEnumerable<ITheInterface> DoMyQuery() { using (ISession session = _sessionFactory.OpenSession()) { var query = ( from c in session.Query<IMyInterface>() where

component collection mapping NHibernate 3.2

被刻印的时光 ゝ 提交于 2020-01-06 03:32:24
问题 I have a Customer which has Addresses: public class Customer { public int Id { get; set; } public string Name { get; set; } public ICollection<Address> Addresses { get; private set; } } public class Address { public string City { get; set; } public string Country { get; set; } public string StreetName { get; set; } public string ZipCode { get; set; } } I want to map this to NHibernate 3.2. which has fluent interface, but not exactly the same as well-known Fluent NHibernate. I know that I have