automapping

Fluent nhibernate automapping collection

巧了我就是萌 提交于 2019-12-04 15:30:17
I am trying to map my collections with FNHib automapping. The problems that I want to solve are: 1) I want all my collections in the project to be mapped via private field. How can I say that globally? 2) Is there any way to automap bidirectional relationship without explicitly overriding each of my entities. class OrganizationEntity example: private ISet<> _collectionWarehouse; public virtual IEnumerable<WarehouseEntity> CollectionWarehouse { get{return _collectionWarehouse; } set{_collectionWarehouse = new HashedSet<WarehouseEntity>((ICollection<WarehouseEntity>)value)} } Class

FluentNHibernate: Automapping OneToMany relation using attribute and convention

眉间皱痕 提交于 2019-12-04 12:19:06
问题 This is very similar to my previous question: FluentNHibernate: How to translate HasMany(x => x.Addresses).KeyColumn("PersonId") into automapping 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 Owner { get; set; } } I want FluentNHibernate to create the following tables: Person PersonId Address

Getting “unable to cast PersistentGenericSet to ISet” error

别来无恙 提交于 2019-12-04 08:52:37
问题 I get this error: Unable to cast object of type 'NHibernate.Collection.Generic.PersistentGenericSet 1[IocWinFormTestEntities.People]' to type 'System.Collections.Generic.ISet 1[IocWinFormTestEntities.People]'. The entity: public class Event { public Event() { this.People = new HashSet<People>(); } public virtual Guid Id { get; private set; } public virtual ISet<People> People { get; set; } } Map override class: public class EventMapOverride : IAutoMappingOverride<Event> { public void Override

Fluent NHibernate DuplicateMappingException with AutoMapping

风格不统一 提交于 2019-12-03 20:21:35
问题 Summary: I want to save two classes of the same name and different namespaces with the Fluent NHibernate Automapper Context I'm writing having to import a lot of different objects to database for testing. I'll eventually write mappers to a proper model. I've been using code gen and Fluent NHibernate to take these DTOs and dump them straight to db. the exception does say to (try using auto-import="false") Code public class ClassConvention : IClassConvention { public void Apply(IClassInstance

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

这一生的挚爱 提交于 2019-12-03 13:03:45
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(SQLiteConfiguration.Standard .ConnectionString(@"Data Source=SqliteTestSqlDataAccess.s3db; Version=3; New=True;

Simple Convention Automapper for two-way Mapping (Entities to/from ViewModels)

好久不见. 提交于 2019-12-03 06:06:50
问题 UPDATE: this stuff has evolved into a nice project, see it at http://valueinjecter.codeplex.com check this out, I just wrote a simple automapper, it takes the value from the property with the same name and type of one object and puts it into another, and you can add exceptions (ifs, switch) for each type you may need so tell me what do you think about it ? I did it so I could do something like this: Product –> ProductDTO ProductDTO –> Product that's how it begun: I use the "object" type in my

Getting “unable to cast PersistentGenericSet to ISet” error

社会主义新天地 提交于 2019-12-03 01:12:56
I get this error: Unable to cast object of type 'NHibernate.Collection.Generic.PersistentGenericSet 1[IocWinFormTestEntities.People]' to type 'System.Collections.Generic.ISet 1[IocWinFormTestEntities.People]'. The entity: public class Event { public Event() { this.People = new HashSet<People>(); } public virtual Guid Id { get; private set; } public virtual ISet<People> People { get; set; } } Map override class: public class EventMapOverride : IAutoMappingOverride<Event> { public void Override(AutoMapping<Event> mapping) { mapping.HasMany(c => c.People) .AsSet() .Cascade.AllDeleteOrphan(); } }

Fluent Nhibernate Automap convention for not-null field

北城以北 提交于 2019-12-01 04:01:36
Could some one help, how would I instruct automap to have not-null for a column? public class Paper : Entity { public Paper() { } [DomainSignature] [NotNull, NotEmpty] public virtual string ReferenceNumber { get; set; } [NotNull] public virtual Int32 SessionWeek { get; set; } } But I am getting the following: <column name="SessionWeek"/> I know it can be done using fluent-map. but i would like to know it in auto-mapping way. Thank you. Also, for reference properties ReferenceConvention need to be done. This is the code that works: public class ColumnNullConvention : IPropertyConvention {

How to solve “Batch update returned unexpected row count from update; actual row count: 0; expected: 1” problem?

房东的猫 提交于 2019-11-30 16:54:31
Getting this everytime I attempt to CREATE a particular entity ... just want to know how I should go about figuring out the cause. I'm using Fluent NHibernate automapping so perhaps I haven't set a convention appropriately and/or need to override somethings in one or more mapping files. I've gone thru a number of posts on the web regarding this problem and having a hard time figuring out exactly why it is happening in my case. The object I'm saving is pretty simple. It is a "Person" object that references a "Company" entity and has a collection of "Address" entities. UPDATES work fine on

How to solve “Batch update returned unexpected row count from update; actual row count: 0; expected: 1” problem?

*爱你&永不变心* 提交于 2019-11-30 00:13:33
问题 Getting this everytime I attempt to CREATE a particular entity ... just want to know how I should go about figuring out the cause. I'm using Fluent NHibernate automapping so perhaps I haven't set a convention appropriately and/or need to override somethings in one or more mapping files. I've gone thru a number of posts on the web regarding this problem and having a hard time figuring out exactly why it is happening in my case. The object I'm saving is pretty simple. It is a "Person" object