fluent-nhibernate

Applying a filter in a Fluent NHibernate mapping using a lambda referencing an inherited property?

北慕城南 提交于 2021-02-08 03:10:38
问题 Is there any way to specify in a fluent nhibernate mapping file a way to only conditionally pull values into a business entity? My current mapping snippet is: HasMany(m => m.GroupUsers) .Table("GroupUsers") .KeyColumns.Add("UserEntityId") .Inverse() .Cascade.All(); Ideally, I'd like to have this (which compiles but throws a runtime error that gu isn't defined): HasMany(m => m.GroupUsers) .Table("GroupUsers") .KeyColumns.Add("UserEntityId") .Where(gu => gu.DeleteDate == null) .Inverse()

Applying a filter in a Fluent NHibernate mapping using a lambda referencing an inherited property?

僤鯓⒐⒋嵵緔 提交于 2021-02-08 03:06:23
问题 Is there any way to specify in a fluent nhibernate mapping file a way to only conditionally pull values into a business entity? My current mapping snippet is: HasMany(m => m.GroupUsers) .Table("GroupUsers") .KeyColumns.Add("UserEntityId") .Inverse() .Cascade.All(); Ideally, I'd like to have this (which compiles but throws a runtime error that gu isn't defined): HasMany(m => m.GroupUsers) .Table("GroupUsers") .KeyColumns.Add("UserEntityId") .Where(gu => gu.DeleteDate == null) .Inverse()

Fluent NHibernate DateTime UTC

一笑奈何 提交于 2021-02-07 09:45:48
问题 I would like to create a fluent nhibernate mapping to map a DateTime field in a following way: On save - Save the UTC value On read - Adjust to local time zone value What is the best way to achieve this mapping? 回答1: Personally, I would store the date in the object in UTC, then convert within the object when reading/writing. You can then reference the backing field your property uses in the mapping (it's not quite as "fluent" to do it this way but you can use FluentNH to map this). If the UTC

nHibernate Euro symbol € change for character ¿

蹲街弑〆低调 提交于 2021-01-28 08:22:37
问题 I've tried save a Euro Symbol € using NHibernate and FluentNHibernate in a database Oracle 11g. I have checked a log from NHibernate and see the generated sql statement: UPDATE CURRENCY SET DESCRIPTION = 'Euro', SYMBOL = '€', WHERE ID = 63 When the query from table CURRENCY execute, the column SYMBOL returns ¿ I've tried change the FluentNHibernate Mapping for the column SYMBOL using AnsiString , like this: Map((x) => x.Symbol).Column("SYMBOL").CustomType("AnsiString").Not.Nullable(); But it

NHibernate One-To-One Relationship

こ雲淡風輕ζ 提交于 2021-01-27 17:10:32
问题 I have the following Domain Model(s) : public class WriteOffApprovalUser { public virtual string UserName { get; set; } public virtual Employee Employee { get; set; } } public class Employee { public virtual string EmployeeID { get; set; } public virtual string EmployeeStatusCode { get; set; } public virtual string FirstName { get; set; } public virtual string LastName { get; set; } public virtual string PreferredName { get; set; } public virtual string JobTitle { get; set; } public virtual

FluentNHibernate set default column value for a bool

跟風遠走 提交于 2020-06-25 04:09:58
问题 How to set with FluentNHibernate the default value of 1 or 0 for a BIT column of the table generated from my entity for the field of type bool. I think it doesn't matter but in any case the database is sqlserver2005. 回答1: Have you tried something like this this.Map(x => x.SomeBitColumn) .Access.Property() .Default("1"); 回答2: You probably want to look at using NHibernate Validator for this, here is an ayende example for something close to what you are looking for. They give greater control

Unable to cast object of type NHibernate.Collection.Generic.PersistentGenericBag to List

淺唱寂寞╮ 提交于 2020-03-08 04:57:46
问题 I have a class called ReportRequest as: public class ReportRequest { Int32 templateId; List<Int32> entityIds; public virtual Int32? Id { get; set; } public virtual Int32 TemplateId { get { return templateId; } set { templateId = value; } } public virtual List<Int32> EntityIds { get { return entityIds; } set { entityIds = value; } } public ReportRequest(int templateId, List<Int32> entityIds) { this.TemplateId = templateId; this.EntityIds = entityIds; } } It is mapped using Fluent Hibernate as:

Are there occasions when NHibernate won't return a proxy object?

百般思念 提交于 2020-02-04 02:57:47
问题 I'm learning Fluent NHibernate (and by extension, NHibernate generally). I'm using auto-mapping with some overrides, but I don't think that is important for the question (of course, if I'm wrong here I'll gladly update the question). Given an ISession (and a few more assumed variables) I can return entities by their ID: using (var session = SessionFactory.OpenSession()) { var user = session.Get<User>(userId); } My limited understanding was that NHibernate creates a proxy around the User

Fluent-Nibernate with wpf: Convention to use uNhAddIns…ObservableListType<T> as default?

放肆的年华 提交于 2020-02-03 10:02:05
问题 I am trying to use Fluent-Nibernate with wpf that require Observable collections (implement the INotifyCollectionChanged interface). At uNHAddins: Unofficial addins for NHibernate i found the uNhAddIns.WPF.Collections.Types.ObservableListType<T> that implements INotifyCollectionChanged . It can be configured in Fluent-Nibernate like this namespace FluentNHibernateTutorial.Mappings { public class StoreMap : ClassMap<Store> { public StoreMap() { Id(x => x.Id); Map(x => x.Name); HasManyToMany(x