fluent-nhibernate-mapping

Invalid index for this SqlParameterCollection with Count

ぃ、小莉子 提交于 2019-12-02 00:04:18
问题 I need access to the ApplicationID property of the parent class in order to run an Nhibernate query. Running a test for this query in NUnit causes it to fail as such: "BusinessObjects.IntegrationTests.CMSEligibilityInfoRepositoryTest.FetchListByApplicationIDTest: System.IndexOutOfRangeException : Invalid index 6 for this SqlParameterCollection with Count=6." This collection of code worked fine before trying to acquire the ApplicationID. The best my research has come up with so far is that it

Invalid index for this SqlParameterCollection with Count

北城以北 提交于 2019-12-01 21:11:22
I need access to the ApplicationID property of the parent class in order to run an Nhibernate query. Running a test for this query in NUnit causes it to fail as such: "BusinessObjects.IntegrationTests.CMSEligibilityInfoRepositoryTest.FetchListByApplicationIDTest: System.IndexOutOfRangeException : Invalid index 6 for this SqlParameterCollection with Count=6." This collection of code worked fine before trying to acquire the ApplicationID. The best my research has come up with so far is that it is a mapping issue. Parent class: public abstract class MemberEligibilityInfo { #region Access

Mapping entity oneToMany with fluent nhibernate

狂风中的少年 提交于 2019-12-01 21:00:16
The problem appears to be simple however I'm having so much trouble trying to map this entities. I just can't see what am I doing wrong. Can you guys help me? I have the class Cliente : public class Cliente { public Cliente () { } public virtual int ClienteId { get; set; } public IList<Medidor> ListaMedidores { get; set; } public virtual string NumeroMedidor { get; set; } } And class Medidor public class Medidor { public Medidor() { } public virtual string NumeroMedidor { get; set; } public virtual string MarcaMedidor { get; set; } public virtual Cliente Cliente { get; set; } } I tried to map

CompositeId causes Could not compile the mapping document error

谁说胖子不能爱 提交于 2019-12-01 01:31:09
问题 I am trying to use CompositeId to map to a legacy system. The source database has a composite primary key so I can't use the normal this.Id mapping. Here is my attempt to map it: public PriorityListPartMap() { this.Schema("EngSchedule"); this.Table("vPriorityListPart"); this.CompositeId().KeyProperty(x => x.AssemblyPartNumber).KeyProperty(x => x.PartNumber); this.Map(x => x.CurrentDueDate); this.Map(x => x.OrderLine); this.Map(x => x.OrderNumber); this.Map(x => x.PartDescription); this.Map(x

Duplicates when eager fetching a reference (many-to-one)

心不动则不痛 提交于 2019-11-30 20:34:33
First of all, yes, I am using DistinctRootEntityResultTransformer. I have the following (Fluent NHibernate) mapping: public FirstObjectMap() { Id(x => x.Id): HasMany<SecondObject>(x => x.SecondItems).KeyColumn("FirstObject_ID"); } public SecondObjectMap() { Id(x => x.Id).Column("ID"); References(x => x.ThirdObject).Column("ThirdObject_ID"); } public ThirdObjectMap() { Id(x => x.Id).Column("ID"); HasMany<D>(x => x.FourthItems).KeyColumn("ThirdObject_ID"); } public FourthObjectMap() { Id(x => x.Id).Column("ID"); } Notice, that SecondObject refers to ThirdObject (meaning the key is on

Duplicates when eager fetching a reference (many-to-one)

天大地大妈咪最大 提交于 2019-11-30 05:24:00
问题 First of all, yes, I am using DistinctRootEntityResultTransformer. I have the following (Fluent NHibernate) mapping: public FirstObjectMap() { Id(x => x.Id): HasMany<SecondObject>(x => x.SecondItems).KeyColumn("FirstObject_ID"); } public SecondObjectMap() { Id(x => x.Id).Column("ID"); References(x => x.ThirdObject).Column("ThirdObject_ID"); } public ThirdObjectMap() { Id(x => x.Id).Column("ID"); HasMany<D>(x => x.FourthItems).KeyColumn("ThirdObject_ID"); } public FourthObjectMap() { Id(x => x

Fluent NHibernate to query stored procedure without an hbm.xml mapping

你。 提交于 2019-11-30 01:07:59
Is there any way to query stored procedure in Fluent Nhibernate without creating an hbm.xml file mapping? icepicker I assume you use the standard Session.GetNamedQuery(.... instead, you can use var result = Session.CreateSQLQuery("exec MyStoredProc :pUserId, :pIsLocked") .AddEntity(typeof(MyDomainObject)) .SetParameter("pUserId", userId) .SetParameter("pIsLocked", isLocked) .List<MyDomainObject>(); This allows you to call the stored proc but still get back a domain object (or list of) without needing a .hbm.xml file. Actually there's this post You should have a class for returning result set

FluentNHibernate - Mapping a class to multiple tables

女生的网名这么多〃 提交于 2019-11-29 17:38:16
Sorry for a lengthy question. But it is worth giving all the details so please bear with me through to the end. I'm working against a legacy database over which I do not have much control. I want to be able to map a class to multiple database tables. Here is how my tables look Lookup +--------+--------------+------------+ | Column | DataType | Attributes | +--------+--------------+------------+ | Id | INT | PK | | Code | NVARCHAR(50) | | +--------+--------------+------------+ Culture +--------------+--------------+------------+ | Column | DataType | Attributes | +--------------+--------------+

FluentNHibernate - Mapping a class to multiple tables

时光怂恿深爱的人放手 提交于 2019-11-28 12:25:10
问题 Sorry for a lengthy question. But it is worth giving all the details so please bear with me through to the end. I'm working against a legacy database over which I do not have much control. I want to be able to map a class to multiple database tables. Here is how my tables look Lookup +--------+--------------+------------+ | Column | DataType | Attributes | +--------+--------------+------------+ | Id | INT | PK | | Code | NVARCHAR(50) | | +--------+--------------+------------+ Culture +-------