fluent-nhibernate

Fluent NHibernate: Prevent class from being mapped

限于喜欢 提交于 2020-01-02 05:38:09
问题 I am sure it is a piece of cake, but I can't find it using google. I need to EXCLUDE a single class from mapping. My current configuration is: return Fluently.Configure() .Database(MsSqlConfiguration.MsSql2005.ConnectionString(c => c.Is(@"Data Source=PC\SQLEXPRESS;......"))) .Mappings(m => m.AutoMappings.Add( AutoPersistenceModel.MapEntitiesFromAssemblyOf<Person2>() .Where(t => t.Namespace == "ExampleData.HumansTest") .UseOverridesFromAssemblyOf<PersonMappingOverrides>() .ConventionDiscovery

Fluent NHibernate error: The entity 'ClassMap`1' doesn't have an Id mapped

你。 提交于 2020-01-02 05:19:05
问题 I'm converting a previous project from using normal NHibernate hbm.xml mappings to Fluent NHibernate. Currently, I'm stuck on what should be one of the last steps to getting this working. I've added a derived class for DefaultAutomappingConfiguration to modify my ID naming convention. The string "Id" is appended to the class name: public override bool IsId(FluentNHibernate.Member member) { return member.Name == member.DeclaringType.Name + "Id"; } This should make "Agency" have an ID in a

working with Fluent NHibernate and guid ids

断了今生、忘了曾经 提交于 2020-01-02 05:08:06
问题 We're working with Fluent NHibernate 1.2 and our primary key is a guid saved in a nvarchar(32) column, working with Oracle 11gr2. How can we make this work? (making an automatic conversion...) Thanks ahead, random programmer... UPDATE: forgot to mention, the guid is saved WITHOUT dashes ... 回答1: Update: You will have to implement your own IUserType to handle the dashless Guids. You can read about it here: http://dotnet.dzone.com/articles/understanding-nhibernate-type The detail below is now

Fluent Nhibernate - Mapping a list results in NullReferenceException?

别等时光非礼了梦想. 提交于 2020-01-01 19:31:11
问题 I have the following classes and fluent mappings: public class A { public virtual int Id { get; private set; } public virtual string MyString { get; set; } public virtual IList<B> MyChildren { get; set; } } public class B { public virtual int Id { get; private set; } public virtual DateTime TheDate { get; set; } } public sealed class AMap : ClassMap<A> { public AMap() { Id(x => x.Id).GeneratedBy.Native().UnsavedValue(0); Map(x => x.MyString); HasMany(x => x.MyChildren).AsList(x => x.Column(

Fluent NHibernate One-to-One mapping

余生颓废 提交于 2020-01-01 16:06:02
问题 I am having a really hard time exploiting HasOne mapping with Fluent NHibernate. Basically, the class A can have a matching (only one or none) record in the class B. Please help with the AMap and BMap classes that define the relationships. Thank you. public class A { public virtual int Id {get;set;} public virtual string P1 {get;set;} public virtual string P2 {get;set;} public virtual string P3 {get;set;} } public class B { public virtual int Id {get;set;} public virtual string P4 {get;set;}

NHibernate throwing Session is closed

冷暖自知 提交于 2020-01-01 12:22:14
问题 I'm flapping in the wind, so I thought I'd ask here... Please let me know if this is obvious and has been answered before. I'm building an MVC 3 site which works fine while I'm running it with one user, where I click through the pages. However, if I madly hit refresh, eventually I hit a "Session is closed". I've isolated out almost all of all my repository to try to get to the bottom, so I know have it erroring on the homepage. The only thing that is being called in the repository is get the

FluentNhibernate IDictionary<Entity,ValueObject>

霸气de小男生 提交于 2020-01-01 12:13:06
问题 I had a mapping for a IDictionary<StocksLocation,decimal> property, this was the mapping: HasMany<StocksLocation>(mq => mq.StocksLocation) .KeyColumn("IDProduct") .AsEntityMap("IDLocation") .Element("Quantity", qt => qt.Type<decimal>()); Now i changed from decimal to a Value Object: Quantity . Quantity has two properties, decimal Value and Unit Unit (where Unit is an enum). I now have to map IDictionary<StocksLocation,Quantity> , how can i achieve this? Thanks in advance 回答1: Option 1: Map it

What is the difference between NHibernate.Mapping.ByCode.Conformist.ClassMapping and FluentNHibernate.Mapping.ClassMap?

耗尽温柔 提交于 2020-01-01 10:07:52
问题 I'm learning about NHibernate, where the class mapping, I learned, is done with XML. I understand that Fluent NHibernate came about as a strongly-typed replacement for the XML-style of mapping. Indeed, here is the fluent-nhibernate tag description: Fluent NHibernate lets you write NHibernate mappings in strongly typed C# code. This allows for easy refactoring, improved readability and more concise code. Then later I was using NHibernate Mapping Generator to create mappings and domain classes

Unable to obtain public key for StrongNameKeyPair

北城以北 提交于 2020-01-01 10:02:04
问题 I have ported developing to another computer and if i run project, i have this exception: Unable to obtain public key for StrongNameKeyPair. HibernateException: Creating a proxy instance failed On original computer it works OK without problems. I found on google that it is problem with some crypting and I should try "sn -m n", by I don't know how. sn.exe is in more folders, i tryed some run from command line but it writes: Failed to open registry key -- Unable to format error message 00000005

FluentNHibernate - Automapping ignore property

末鹿安然 提交于 2020-01-01 06:54:09
问题 I have a base class that contains a property called IsDirty. This is used for the domain model and is not a column in the database table. When using automapping, fluent nhibernate tries to add this column to the table. A way to fix this is to put .ForTypesThatDeriveFrom<Address>(p => p.IgnoreProperty(x => x.IsDirty)) in the automapping setup. The problem is, all my entities will do this, is there a way to state this without have to add this line for every entity? If I put