mapping-by-code

NHibernate 3.2 By Code (Conformist) ClassMapping For a Dictionary Property

限于喜欢 提交于 2020-01-14 14:14:12
问题 Assume I have a class "SomeClass" that has a lookup dictionary: DataDictionary; I currently have a mapping in SomeClass.hbm.xml like this: <class name="SomeClass> <id name="ID" type="System.Guid"> <generator class="guid" /> </id> <map name="DictionaryProperty" table="SomeClass_Data"> <key column="SomeClassID" /> <index column="Key" type="System.String" /> <element column="Value" type="System.String" /> </map> </class> I want to use NHibernate's new (version 3.2) By Code mappings. How would I

FluentNHibernate or port to NHibernate mapping by code

这一生的挚爱 提交于 2020-01-14 08:07:08
问题 I have several projects using NH and FNH to generate the mappings (some Fluent some Automapped). There are still some bugs and missing features i need, but it seems that FNH could die because of mapping-by-code integrated into NHibernate. Question: Contribute to FNH or to migrate the mappings to mapping-by-code or confORM and fixing problems/implementing features there? 回答1: At our office, we have been using NHibernate for 3 years now. We've been thinking about making a move to Fluent

NHibernate: cannot resolve inherited id property

混江龙づ霸主 提交于 2020-01-04 04:53:08
问题 I have the entity defined below: public class Foo : Entity<Foo.FooId> { public class FooId { public virtual String Bar { get; protected internal set; } public virtual Int32 Buzz { get; protected internal set; } } // ... } And here's the base class: public abstract class Entity<T> : IEquatable<Entity<T>> { public virtual T Id { get; protected internal set; } // ... } I'm going to map the "Id" property as a "composite key", so I've added the following mapping class: public class FooMap :

Ignore column using mapping by code in HNibernate

混江龙づ霸主 提交于 2019-12-24 10:48:55
问题 I'm using mapping by code in NHibernate. I got a class with several properties. One of them is not related to any columns in DB but still has getter and setter. I use ConventionModelMapper not ModelMapper. The first one assumes that all properties are mapped. How i can tell to NHibernate to ignore it? 回答1: Why not map the properties you want and leave the ones not needed to be mapped check this You can manage the persistence of ConventionModelMapper as following: mapper.BeforeMapProperty +=

How to map a sql function as named query with Nhibernate's loquacious mapping?

心已入冬 提交于 2019-12-13 19:12:26
问题 I have replaced all my NHibernate xml mapping files by loquacious mappings (mapping by code). The only thing I can't figure out is if it is possible to define this named query using loquacious mappings: <?xml version="1.0" encoding="utf-8"?> <hibernate-mapping namespace="Domain" assembly="Domain" xmlns="urn:nhibernate-mapping-2.2"> <sql-query name="MyFunction"> <query-param name="Inputparam1" type="Int32"/> <query-param name="Inputparam2" type="Int32"/> <return-scalar column="ResultParam"

Simple get using NHibernate (using mapping-by-code) is extremely slow

不问归期 提交于 2019-12-13 12:31:43
问题 So i've run out of ideas as to why this is so slow. Maybe you can help. So I am trying to do a simple get on record from an oracle db using nHibernate mapping by code. I'm using nHibernate verison 3.3.1.4 from nuget. Here is the mapping code: public class Person { public virtual PersonKey Key { get; set; } public virtual string FirstName { get; set; } public virtual string LastName { get; set; } } public class PersonKey { public virtual string PersonId { get; set; } public override bool

one to one mapping in NHibernate 3.2 mapping by code

拟墨画扇 提交于 2019-12-12 15:54:02
问题 I'm trying to learn NHibernate 3.2 built-in mapping by code api ( NOT Fluent NHibernate ). Can you help me to map a one-to-one(or zero) relationship between these entities please? NOTE: I googled the question, also I search the SOF, all examples are using Fluent API or xml; I'm trying to use built-in mapping api in NHibernate 3.2 public class Person { public virtual int Id { get; set; } public virtual string FirstName { get; set; } public virtual string LastName { get; set; } // can be null

NHibernate: Mapping protected members in component (composite-element) mapping

怎甘沉沦 提交于 2019-12-12 04:48:52
问题 I'm building an application which uses NHibernate mapping by code, and I am unable to map protected properties when I use a component mapping (equivalent to hbm composite-element mapping) for a collection of value objects. I am able to map protected properties in entity and compoment mappings for single value objects, it is just protected properties do not appear to be supported when mapping collections of value objects. public class MyEntity { public virtual int Id { get; protected set; }

Bi-directional NHibernate mapping by code

╄→尐↘猪︶ㄣ 提交于 2019-12-11 05:41:31
问题 Just to be clear - this question is not about Fluent NHibernate. I have a Parent and Child classes, with a one-to-many relationship between them. The code is shortened for readability. public class Child { int Id; string Name; } public class Parent { int Id; string Name; Iesi.Collections.Generic.ISet<Child> Children; } public ChildMapping() { Table("Children"); Id(p => p.Id, m => { m.Column("Id"); m.Generator(Generators.Identity); }); Property(p => p.Name, m => { m.Column("Name"); m

NHibernate 3.2 Mapping IDictionary By Code

对着背影说爱祢 提交于 2019-12-11 01:35:29
问题 I'm having a problem mapping to IDictionary using the new Loquacious configuration. Here's the class: public class Person { public Person() { Description = new Dictionary<int, string>(); } public virtual int Id { get; set; } // can be in various languages public virtual IDictionary<int, string> Resources { get; set; } } public class PersonResource { public virtual string Description { get; set; } } Here's the mapping: public class TestPersonMap : ClassMapping<TestPerson> { Table("TestPersons"