fluent-nhibernate

Fluent NHibernate Automappings generating 2 foreign keys for 1 relationship

跟風遠走 提交于 2019-12-12 04:59:59
问题 I have this setup (condensed for brevity) Class Employee virtual IList<ChecklistItem> HasInitialed { get; private set; } Class ChecklistItem virtual Employee InitialedBy { get; set; } When this is generated I get these tables Employee Id ChecklistItem Id InitialedBy_id <---- Employee_id <---- The ChecklistItem has 2 foreign keys for Employee, I'm assuming Employee_id to map ChecklistItem.Employee and InitialedBy_id to map ChecklistItem.InitialedBy. How can I tell NHibernate that this is the

Mapping RefrencesAny (multiple tables) with fluent nhibernate

断了今生、忘了曾经 提交于 2019-12-12 04:59:11
问题 I am trying to follow this post using Fluent NHIbernate: http://blogs.planetcloud.co.uk/mygreatdiscovery/post/Localizing-entities-with-NHibernate.aspx My test generates the following error: ----> NHibernate.MappingException : An association from the table TranslatedText refers to an unmapped class: .Domain.Localisation.ILocalizedEntity Any idea how to get NH to honour the interface? Adding .IncludeBase<ILocalizedEntity>() to my auto model did nothing... (as expected its an interface not an

Fluent NHibernate Many-To-Many Mapping with 3 classes

江枫思渺然 提交于 2019-12-12 04:59:03
问题 First, I'm using NHibernate 3.2 and FluentNHibernate 1.3. I have 3 clasess: public class ClassA { public virtual Int32 Id{ get; } .... public ICollection<ClassB> ClassesB { get; } public ICollection<ClassC> ClassesC { get; } } public class ClassB { public virtual Int32 Id{ get; } .... public ICollection<ClassA> ClassesA { get; } public ICollection<ClassC> ClassesC { get; } } public class ClassC { public virtual Int32 Id{ get; } .... public ICollection<ClassA> ClassesA { get; } public

Fluent NHibernate 3 table relation without primary and foreign keys

て烟熏妆下的殇ゞ 提交于 2019-12-12 04:54:31
问题 Background Info I have the following class that I want to map with NHibernate: public class Player { public virtual int Id { get; set; } public virtual Type Type { get; set; } public virtual string ScreenName { get; set; } public virtual bool Unsubscribed { get; set; } } On the database side, I have the following tables: -- New table Player ( int Id int TypeId (not null) -- foreign-key to Type table string ScreenName (not null) -- can be an EmailAddress, but not necessarily ) Type ( int Id

Database permissions in MVC with NHibernate

爱⌒轻易说出口 提交于 2019-12-12 04:41:07
问题 I'm working on an intranet MVC web application, using Fluent NHibernate. As everyone knows, creating the necessary ISessionFactory is heavy, and therefore should be done only once. Hence, I create it in the Global.asax file during Application_Start , then cache it in the application for future use. The problem is that I only want to give access to users who already have permissions over the database. This could theoretically be solved by defining Integrated Security=SSPI in the connection

Null Reference Exception during Fluent NHibernate Configuration from App.Config File

纵然是瞬间 提交于 2019-12-12 04:32:55
问题 Scenario: See Heading. Description: Please See Screenshot. Alternative: Tried using appsettings too .ConnectionString(c=>c.FromAppSetting(conStr))) Same error for this one too. 来源: https://stackoverflow.com/questions/11192842/null-reference-exception-during-fluent-nhibernate-configuration-from-app-config

Nhinerbate lazy loading of reference entity

柔情痞子 提交于 2019-12-12 04:22:42
问题 I have this scenario: class A { public virtual int Id { get; set; } public virtual B Child { get; set; } } class B { public virtual int Id { get; set; } } In the mapping of class A, I have a reference to class B: map.Reference(a => a.Child).LazyLoad(); Now when I do something like: Session.Query<TypeOfA>().Select(a => a); Apart from the normal select * from ATable I get n selects from the BTable for each A line. Is like lazy loading is not working. My questions are: How to I make the lazyload

Fluent Nhibernate loading not falling back on lazy loading? (grandchild entities)

不打扰是莪最后的温柔 提交于 2019-12-12 04:18:27
问题 When querying nhibernate, I'm seeing some odd behavior When I write a query like this Repository.QueryOver<Entity>() .Fetch(x => x.Child1).Eager .Fetch(x => x.child2).Eager It will eagerly grab child1 and child2 entities, but there are grandchildren for child1 and child2 that aren't lazily loaded. I'm a bit confused on how to achieve this. In my nhibernate mappings, it seems to have no affect on the laziness or eagerness of grandchildren and I require at least some entities be eagerly loaded

Fluent Nhibernate many-to-many issue

无人久伴 提交于 2019-12-12 04:15:21
问题 I have three tables: Person (Id, FirstName) Organization (Id, Name) PersonOrganization (PersonId, OrganizationId, Details) many-to-many table When I first mapped this using Fluent NHibernate I did not have a details column in the PersonOrganization table and mapped this using HasManyToMany in the PersonMap and OrganizationMap (no need to create a PersonOrganization domain object or map). I could writethe following code: Organization org = new Organization { Name = "org" }; People people = new

Fluent Nhibernate: ignore interfaces/abstract classes during BuildSchema or UpdateSchema

允我心安 提交于 2019-12-12 03:47:10
问题 Edit I've got an interface that I'd like to base some classes on. When I go to BuildSchema (or UpdateSchema), Nhibernate creates a table for the interface. I thought I found a work-around as follows: The Interface and Classes: public interface ILevel { int Id { get; set; } string Name { get; set; } } public abstract class Level : ILevel { public virtual int Id { get; set; } public virtual string Name { get; set; } } public class LevelOne : Level { } public class LevelTwo : Level { } The