nhibernate

Nhibernate mapped internal classes and InternalsVisibleTo

点点圈 提交于 2020-01-01 18:17:34
问题 My proxy generator is having trouble generating proxies for internal mapped Nhibernate classes. I have tried adding them as visible using InternalsVisibleTo in assemblyinfo.cs but it doesn't seem to work. Worse, I don't know how to tell if I've even successfully managed to friend the proxy assemblies I want to because if I change a few numbers in the proxy assemblies public key in assemblyinfo.cs there is no error thrown. Error: Test method TestProject1.UnitTest1.TestMethod1 threw exception:

Register Multiple Components for Single Interface Using Castle Windsor

久未见 提交于 2020-01-01 18:05:30
问题 I am trying to register multiple NHibernate ISessions (multiple databases) by using the code below. I am getting "There is a component already registered for the given key Castle.MicroKernel.Registration.GenericFactory`1[[NHibernate.ISession, NHibernate, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4]]" as the error message when the container is trying to be built. container.Kernel.Register( Component.For<ISession>().LifeStyle.Transient .UsingFactoryMethod(() =>

NHibernate HQL logic problem

走远了吗. 提交于 2020-01-01 16:33:11
问题 I'm trying to write an NHibernate HQL query that makes use of parenthesis in the where clause. However, the HQL parser seems to be ignoring my parenthesis, thus changing the meaning of my statement. Can anyone shed any light on the matter? The following HQL query: from WebUser u left join fetch u.WebUserProfile left join fetch u.CommunicationPreferences where (u.CommunicationPreferences.Email = 0 and u.SyncDate is not null) or u.DateDeleted is not null translates to: from WebUser webuser0_

Fluent NHibernate One-to-One mapping

余生颓废 提交于 2020-01-01 16:06:02
问题 I am having a really hard time exploiting HasOne mapping with Fluent NHibernate. Basically, the class A can have a matching (only one or none) record in the class B. Please help with the AMap and BMap classes that define the relationships. Thank you. public class A { public virtual int Id {get;set;} public virtual string P1 {get;set;} public virtual string P2 {get;set;} public virtual string P3 {get;set;} } public class B { public virtual int Id {get;set;} public virtual string P4 {get;set;}

Return class from nested collection using NHibernate

不问归期 提交于 2020-01-01 15:53:29
问题 Doman: class Action Products: IList of class ActionProducts: Category: class Category Products: IList of class Product Now, I want this: var products = from a in Session.Linq<Action>() from ap in a.Products from p in ap.Category.Products where a.Name == name select p; And this Linq actually works but: 1. produces select for all tables instead of only Products 2. produces left outer joins, not inner 3. Distinct() on the query doesn't work (though ToList().Distinct() works). Also can be done

Return class from nested collection using NHibernate

天涯浪子 提交于 2020-01-01 15:53:13
问题 Doman: class Action Products: IList of class ActionProducts: Category: class Category Products: IList of class Product Now, I want this: var products = from a in Session.Linq<Action>() from ap in a.Products from p in ap.Category.Products where a.Name == name select p; And this Linq actually works but: 1. produces select for all tables instead of only Products 2. produces left outer joins, not inner 3. Distinct() on the query doesn't work (though ToList().Distinct() works). Also can be done

nHibernate.Search with nHibernate v2

醉酒当歌 提交于 2020-01-01 14:39:31
问题 I having trouble getting nHibernate.Search to create an Index. If I use 1.2.1.4 of nHibernate.dll & nHibernate.Search.dll then the index is created correctly and I can inspect it with Luke (a Lucene utility). A segments file is created as well as a Fragments file etc However, when I use v 2 of nHibernate.dll & nHibernate.Search.dll then the index is not created correctly. Only a 1k segments file is created in the Index directory and Luke is unable to inspect it. The code I used in v1 was as

Eager loading child and child-of-child collections in NHibernate

女生的网名这么多〃 提交于 2020-01-01 12:48:46
问题 I've got a problem with NHibernate trying to load a small hierarchy of data. My domain model looks like: class GrandParent { int ID{get;set;} IList<Parent> Parents {get; set;} } class Parent { IList<Child> Children {get; set;} } class Child { } and I would like to eager load all parents and children for a given GrandParent. This Linq-to-NH query creates the correct SQL and loads the GrandParent as expected: (the example assumes the grandparent has 2 parents who each have 2 child objects - so

NHibernate throwing Session is closed

冷暖自知 提交于 2020-01-01 12:22:14
问题 I'm flapping in the wind, so I thought I'd ask here... Please let me know if this is obvious and has been answered before. I'm building an MVC 3 site which works fine while I'm running it with one user, where I click through the pages. However, if I madly hit refresh, eventually I hit a "Session is closed". I've isolated out almost all of all my repository to try to get to the bottom, so I know have it erroring on the homepage. The only thing that is being called in the repository is get the

FluentNhibernate IDictionary<Entity,ValueObject>

霸气de小男生 提交于 2020-01-01 12:13:06
问题 I had a mapping for a IDictionary<StocksLocation,decimal> property, this was the mapping: HasMany<StocksLocation>(mq => mq.StocksLocation) .KeyColumn("IDProduct") .AsEntityMap("IDLocation") .Element("Quantity", qt => qt.Type<decimal>()); Now i changed from decimal to a Value Object: Quantity . Quantity has two properties, decimal Value and Unit Unit (where Unit is an enum). I now have to map IDictionary<StocksLocation,Quantity> , how can i achieve this? Thanks in advance 回答1: Option 1: Map it