fluent-nhibernate

Reference an entity with a formula in Fluent NHibernate

天涯浪子 提交于 2019-12-07 05:19:44
问题 I have a schema with an N:1 parent-child relationship that is stored in another table and is selected by a formula. Is it possible to map this entity to the parent using a formula? public class ParentEntity { public virtual int ParentId { get; set; } public virtual ChildEntity Child{ get; set; } } public class ParentMapping : ClassMap<ParentEntity> { public ParentMapping() { Table("ParentTable"); Id(x => x.ParentId).Column("ParentId").GeneratedBy.Assigned().Not.Nullable(); References

What is the best way to provide an AutoMappingOverride for an interface in fluentnhibernate automapper

末鹿安然 提交于 2019-12-07 05:13:30
问题 In my quest for a version-wide database filter for an application, I have written the following code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using FluentNHibernate.Automapping; using FluentNHibernate.Automapping.Alterations; using FluentNHibernate.Mapping; using MvcExtensions.Model; using NHibernate; namespace MvcExtensions.Services.Impl.FluentNHibernate { public interface IVersionAware { string Version { get; set; } } public class VersionFilter

Fluent NHibernate AutoMapping with discriminator

╄→尐↘猪︶ㄣ 提交于 2019-12-07 04:35:36
问题 I'm trying to map inheritance with discriminator, but subclasses don't have discriminator value. How to solve it using AutoMappings? Domain objects are as following: public abstract class Item : GuidIdentityEntity { public virtual string Name { get; set; } } public class Product : Item {} public class RawMaterial : Item {} Configuration looks like: AssemblyOf<Item>() .IgnoreBase<GuidIdentityEntity>(); .IncludeBase<Item>(); .Setup(setup => { setup.DiscriminatorColumn = type => "Discriminator";

How do you ignore/persist values in MVC when your view-model doesn't have as many fields as your domain model?

与世无争的帅哥 提交于 2019-12-07 03:52:29
问题 I have a site where I'm using fluentNhibernate and Asp.net MVC. I have an Edit view that allows user to edit 8 of the 10 properties for that record (object). When you submit the form and the Model binds, the two un-editable fields come back in the view-model as Empty strings or as default DateTime values depending on the type of property. Because I'm also using AutoMapper to map my view-model to my Domain Entity, I cannot just load a fresh copy of my object from the database and manually set

Mapping custom enum classes with Fluent Nhibernate

一世执手 提交于 2019-12-07 03:30:42
问题 Reading some posts from Jimmy Boggard and wondering - how exactly is it possible to map those beasts with fluent nhibernate? How mapping would look like for this? public class EmployeeType : Enumeration{ public static readonly EmployeeType Manager = new EmployeeType(0, "Manager"), Servant = new EmployeeType(1, "Servant"), AssistantToTheRegionalManager = new EmployeeType (2, "Assistant to the Regional Manager"); private EmployeeType() { } private EmployeeType(int value, string displayName) :

NHibernate: System.Argument Exception : An item with the same key has already been added

試著忘記壹切 提交于 2019-12-07 02:19:55
问题 I'm getting a sporadic error that is difficult to reproduce. My first guess is that somehow I have a leaking nhibernate session, however when I ran the nhibernate profiler, I didn't see much out of the ordinary. MVC 2.0 Fluent version 1.1.0.685 NHibernate version 2.1.2.4000 Exception: System.ArgumentException : An item with the same key has already been added. Stack Trace: at System.Collections.Generic.Dictionary 2.Insert(TKey key, TValue value, Boolean add) at NHibernate.Util

How to solve this exception “Could not find a setter for property 'ProductCode' in class … ”

六眼飞鱼酱① 提交于 2019-12-06 22:44:47
问题 I am getting the following exception: "Could not find a setter for property 'ProductCode'in class ...OrderItem.class " The property (ProductCode) is one of my table keys. see how is the property declaration in the class. public class OrderItem : EntityBase { public virtual short Company { get; set; } public virtual int Order { get; set; } public virtual string Seri { get; set; } public virtual string ProductCode { get; set; } public virtual string Crop { get; set; } . . . } below this my

Fluent-NHibernate many-to-many cascade does not populate the link table

谁说我不能喝 提交于 2019-12-06 19:37:39
问题 OK, no matter how I define these mappings, my many-to-many mapping does not want to work with cascade insert. I have tried various combination of Cascade() with Reverse() and removing all unnecessary properties just to understand if they had anything to do with this not working, but no lock. It is really Simple stuff: I have a Message (like an email) which is sent from a user (I have called the entity BasicUser ) to a number of users (through property To ). User and Message in terms of

Fluent NHibernate primary key constraint naming conventions

こ雲淡風輕ζ 提交于 2019-12-06 18:29:47
问题 Is there any way to create a naming convention for my primary key constraints in Fluent NHibernate? I know you can name foreign key constraints, but it does not appear possible to name the primary key constraint. 回答1: James Gregory from FNH says... No, that's not supported through NHibernate, so we can't support it either. http://groups.google.com/group/fluent-nhibernate/browse_thread/thread/9ea7155407d33772 来源: https://stackoverflow.com/questions/1358043/fluent-nhibernate-primary-key

nHibernate HQL - entity is not mapped

倖福魔咒の 提交于 2019-12-06 17:39:59
问题 I have my nHibernate setup and working correctly with QueryOver for most queries, however, whenever I try to do a HQL CreateQuery I get the exception that the entity isn't mapped. I can confirm that the same entity works fine using QueryOver. Note: I am using fluent nHibernate Any ideas what would cause this? 回答1: If you have disabled auto-import in your mappings ( <hibernate-mapping auto-import="false"> ), then you will have to use fully-qualified class names everywhere in your queries,