automapping

Automapping a Composite Model with Composite Iteration with FluentNhibernate

怎甘沉沦 提交于 2020-01-05 12:06:10
问题 I have a tree structured model and designed it with composite Pattern. for iterating through the entire hierachy Im using Composite Iteration. I have used this tutorial: http://www.blackwasp.co.uk/Composite.aspx but when I want to AutoMap the model, I encounter this problem: {"The entity '<GetEnumerator>d__0' doesn't have an Id mapped. Use the Id method to map your identity property. For example: Id(x => x.Id)."} but getEnumerator is a method. I don't know why handle this like an Entity!!

Getting error “Association references unmapped class” when using interfaces in model

丶灬走出姿态 提交于 2020-01-03 05:43:04
问题 I'm trying to use the automap functionality in fluent to generate a DDL for the following model and program, but somehow I keep getting the error "Association references unmapped class: IRole" when I call the GenerateSchemaCreationScript method in NHibernate. When I replace the type of the ILists with the implementation of the interfaces (User and Role) everything works fine. What am I doing wrong here? How can I make fluent use the implemented versions of IUser and IRole as defined in Unity?

FluentNHibernate: How to translate HasMany(x => x.Addresses).KeyColumn(“PersonId”) into automapping

偶尔善良 提交于 2020-01-03 01:43:26
问题 Say I have these models: public class Person { public virtual int Id { get; private set; } public virtual ICollection<Address> Addresses { get; private set; } } public class Address { public virtual int Id { get; private set; } public virtual Person Person { get; set; } } I want FluentNHibernate to create the following tables: Person PersonId Address AddressId PersonId This can be easily achieved by using fluent mapping: public class PersonMapping : ClassMap<Person> { public PersonMapping() {

Fluent NHibernate: Mapping HasManyToMany by convention

。_饼干妹妹 提交于 2020-01-02 10:18:25
问题 I'm using Fluent NHibernate's AutoMap feature to map my entities. Most of my entities inherit from a base class Entity which has a property public IList<Tag> Tags . The tags are in a separate table in the database, so I use a many-to-many relation. But Fluent NHibernate creates mappings for a one-to-many relation. I'd like to write a convention to override these mappings to use HasManyToMany(...) if the class inherits from Entity . Is this possible and how? The convention could either rely on

Fluent NHibernate: Mapping HasManyToMany by convention

杀马特。学长 韩版系。学妹 提交于 2020-01-02 10:16:07
问题 I'm using Fluent NHibernate's AutoMap feature to map my entities. Most of my entities inherit from a base class Entity which has a property public IList<Tag> Tags . The tags are in a separate table in the database, so I use a many-to-many relation. But Fluent NHibernate creates mappings for a one-to-many relation. I'd like to write a convention to override these mappings to use HasManyToMany(...) if the class inherits from Entity . Is this possible and how? The convention could either rely on

Fluent NHibernate: Mapping HasManyToMany by convention

江枫思渺然 提交于 2020-01-02 10:15:46
问题 I'm using Fluent NHibernate's AutoMap feature to map my entities. Most of my entities inherit from a base class Entity which has a property public IList<Tag> Tags . The tags are in a separate table in the database, so I use a many-to-many relation. But Fluent NHibernate creates mappings for a one-to-many relation. I'd like to write a convention to override these mappings to use HasManyToMany(...) if the class inherits from Entity . Is this possible and how? The convention could either rely on

how to achieve table per concrete class when base class is abstract in fluent nhibernate?

这一生的挚爱 提交于 2020-01-01 02:38:26
问题 i have the following scenario public abstract class BaseClass { public virtual int Id {get; set}; public virtual string Name {get; set;} } public class FirstSubClass : BaseClass { //properties and behaviour here } public class SecondSubClass : BaseClass { //properties of SecondSubclass Here } public class ProcessStep { public virtual IList<BaseClass> ContentElements {get; set;} } for mapping i have used following code snippet :- this._sessionFactory = Fluently.Configure().Database

Fluent NHIbernate automapping of List<string>?

二次信任 提交于 2019-12-29 04:42:20
问题 Fluent NHibernate doesn't like this, throwing an error: {"Association references unmapped class: System.String"} OK fine, I can see why this would cause a problem - but what's the best solution? I don't really want it to store a delimited list of strings in a single field, this would get ugly if my list contains many strings. I also don't really want a table 'string', for obvious reasons. I guess I can solve this by wrapping my List<string> inside a class, but this feels a little heavyweight.

Castle Windsor, Fluent Nhibernate, and Automapping Isession closed problem

好久不见. 提交于 2019-12-23 19:28:38
问题 I'm new to the whole castle Windsor, Nhibernate, Fluent and Automapping stack so excuse my ignorance here. I didn't want to post another question on this as it seems there are already a huge number of questions that try to get a solution the Windsor nhib Isession management problem, but none of them have solved my problem so far. I am still getting a ISession is closed exception when I'm trying to call to the Db from my Repositories,Here is my container setup code. container.AddFacility

Fluent NHibernate: Mixing Automapping and manual mapping

久未见 提交于 2019-12-22 04:45:12
问题 If using Fluent NHibernate, is it possible to automap most classes, but specify that a couple of particular classes should be mapped using the regular fluent API rather than being automapped? And if so, can anyone point me to some sample code that shows how to do it? Thanks! 回答1: It is possible and easy to mix-up mapping configurations: var cfg = Fluently.Configure() .Database(configurer) .Mappings(map => { // Automapping map.AutoMappings.Add(AutoMap.Assemblies(Assembly.GetExecutingAssembly()