automapping

Fluent NHibernate and computed properties

南楼画角 提交于 2019-12-19 09:06:21
问题 I'm using Fluent NHibernate, and auto-mapping the classes. I have a computed property in a class along the lines of public virtual DateTime? LastActionTimeStamp { get { return Actions.Count == 0 ? null : Actions.OrderByDescending( a => a.TimeStamp).ElementAt(0).TimeStamp; } } This wasn't mapped with the rest of the properties, so I couldn't use it in an ICriteria restriction. I added an empty setter (as I read somewhere that doing so would include it in the mapping, which it does), but now I

Fluent NHibernate and computed properties

拜拜、爱过 提交于 2019-12-19 09:05:17
问题 I'm using Fluent NHibernate, and auto-mapping the classes. I have a computed property in a class along the lines of public virtual DateTime? LastActionTimeStamp { get { return Actions.Count == 0 ? null : Actions.OrderByDescending( a => a.TimeStamp).ElementAt(0).TimeStamp; } } This wasn't mapped with the rest of the properties, so I couldn't use it in an ICriteria restriction. I added an empty setter (as I read somewhere that doing so would include it in the mapping, which it does), but now I

Fluent Nhibernate Automap convention for not-null field

允我心安 提交于 2019-12-19 06:31:36
问题 Could some one help, how would I instruct automap to have not-null for a column? public class Paper : Entity { public Paper() { } [DomainSignature] [NotNull, NotEmpty] public virtual string ReferenceNumber { get; set; } [NotNull] public virtual Int32 SessionWeek { get; set; } } But I am getting the following: <column name="SessionWeek"/> I know it can be done using fluent-map. but i would like to know it in auto-mapping way. 回答1: Thank you. Also, for reference properties ReferenceConvention

Fluent Nhibernate Automap convention for not-null field

。_饼干妹妹 提交于 2019-12-19 06:31:17
问题 Could some one help, how would I instruct automap to have not-null for a column? public class Paper : Entity { public Paper() { } [DomainSignature] [NotNull, NotEmpty] public virtual string ReferenceNumber { get; set; } [NotNull] public virtual Int32 SessionWeek { get; set; } } But I am getting the following: <column name="SessionWeek"/> I know it can be done using fluent-map. but i would like to know it in auto-mapping way. 回答1: Thank you. Also, for reference properties ReferenceConvention

Fluent NHibernate enforce Not Nullable on Foreign Key Reference

≡放荡痞女 提交于 2019-12-18 17:07:22
问题 Just getting my feet wet with some Fluent NHibernate AutoMap conventions, and ran into something I couldn't figure out. I assume I'm just not looking in the right place... Basically trying to enforce NOT-NULL on the "many" side of the one to many relationship. It seems, using the automapping, it always makes the parent property Id nullable in the database. I did some searching on StackOverFlow and found similar questions, but nothing relating to AutoMapping and Conventions though (unless I

C# - IDataReader to Object mapping using generics

只谈情不闲聊 提交于 2019-12-18 04:06:13
问题 How can I map a DataReader object into a class object by using generics? For example I need to do the following: public class Mapper<T> { public static List<T> MapObject(IDataReader dr) { List<T> objects = new List<T>(); while (dr.Read()) { //Mapping goes here... } return objects; } } And later I need to call this class-method like the following: IDataReder dataReader = DBUtil.Fetchdata("SELECT * FROM Book"); List<Book> bookList = Mapper<Book>.MapObject(dataReder); foreach (Book b in bookList

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

Issue With Fluent Nhibernate Automapping and Guids / UniqueIdentifiers as Primary Key Fields

爱⌒轻易说出口 提交于 2019-12-11 10:19:48
问题 I am attempting to use the Fluent-NHibernate automapping functionality (in the latest version of the software) and am running into problems using Guids as the Primary Key fields. If I use integer fields for the primary keys, the tables are generated successfully and all Nhibernate functionality seems to work fine. FYI, I am using NHibernate to generate my database tables. Here are a couple of classes with integer IDs. using System; using System.Collections; using System.Collections.Generic;

Can Fluent NHibernate's AutoMapper handle Interface types?

半腔热情 提交于 2019-12-11 04:35:27
问题 I typed this simplified example without the benefit of an IDE so forgive any syntax errors. When I try to automap this I get a FluentConfigurationException when I attempt to compile the mappings - "Association references unmapped class IEmployee ." I imagine if I were to resolve this I'd get a similar error when it encounters the reference to IEmployer as well. I'm not opposed to creating a ClassMap manually but I prefer AutoMapper doing it instead. public interface IEmployer { int Id{ get;

S#arp Architecture many-to-many mapping overrides not working

巧了我就是萌 提交于 2019-12-11 01:48:06
问题 I have tried pretty much everything to get M:M mappings working in S#arp Architecture. Unfortunately the Northwind example project does not have a M:M override. All worked fine in my project before converting to S#arp and its choice of Fluent NHibernate's Auto mapping. I like the auto-mapping, it's good, however the overrides do not seem to register. It all seems to work in memory and in tests, however when committing data to a database nothing gets inserted into my M:M reference table. If we