automapping

AutoMapping Custom Collections with FluentNHibernate

瘦欲@ 提交于 2019-12-11 00:09:31
问题 I am retrofitting a very large application to use NHibernate as it's data access strategy. Everything is going well with AutoMapping. Luckily when the domain layer was built, we used a code generator. The main issue that I am running into now is that every collection is hidden behind a custom class that derives from List<>. For example public class League { public OwnerList owners {get;set;} } public class OwnerList : AppList<Owner> { } public class AppList<T> : List<T> { } What kind of

Fluent Nhibernate AutoMapping Inheritance and Ignoring an Abstract Property

若如初见. 提交于 2019-12-10 11:19:51
问题 I have an inheritance structure that i have succesfully mapped Product (base) PdfProduct (inherits from Product) & OtherProduct(inherits from Product) These are working fine and i have done a simmilar thing before with hmb.xml files. In the previous project i had a problem when i was trying to find out what type the product was but i couldnt do it as it was a Proxy (product is PdfProdcut). To solve this, i added an abstract property to the base Product and overrided it in the other classes

How can I use Fluent NHibernate Automapping with multiple Lists of the same type in an Entity?

人走茶凉 提交于 2019-12-09 12:02:41
问题 It appears that NHibernate cannot automap more than one IList of a given type in an entity. Consider the following two entities (based on the Examples.FirstProject sample code that is included with the Fluent NHibernate source code). public class Employee { public virtual int Id { get; private set; } public virtual string FirstName { get; set; } public virtual string LastName { get; set; } } public class Store { public virtual int Id { get; private set; } public virtual IList<Employee> Staff

How do I use Fluent NHibernate ReferencesAny mapping?

只谈情不闲聊 提交于 2019-12-08 11:59:49
问题 I've read a lot about Fluent NHibernate's ReferencesAny but I haven't seen a complete example. I think I understand most of it, but there is one part I don't get. In the class mapping ReferencesAny(x => x.MemberName) is used to define the relationship to the one or more referenced classes. What is MemberName ? How is it defined and how is it used to create the data in the database. I have three tables, the records in one table can reference records in one of the other two tables. The first

How do I map a dictionary using Fluent NHibernate automapping?

烂漫一生 提交于 2019-12-08 01:38:30
问题 I have an entity like so: public class Land { public virtual IDictionary<string, int> Damages { get; set; } // and other properties } Every time I try to use automapping with the following code: var sessionFactory = Fluently.Configure() .Database(SQLiteConfiguration.Standard.InMemory) .Mappings(m => m.AutoMappings.Add(AutoMap.AssemblyOf<Land>)) .BuildSessionFactory(); I get the following error: {"The type or method has 2 generic parameter(s), but 1 generic argument(s) were provided. A generic

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

How do I map a dictionary using Fluent NHibernate automapping?

大憨熊 提交于 2019-12-06 13:39:19
I have an entity like so: public class Land { public virtual IDictionary<string, int> Damages { get; set; } // and other properties } Every time I try to use automapping with the following code: var sessionFactory = Fluently.Configure() .Database(SQLiteConfiguration.Standard.InMemory) .Mappings(m => m.AutoMappings.Add(AutoMap.AssemblyOf<Land>)) .BuildSessionFactory(); I get the following error: {"The type or method has 2 generic parameter(s), but 1 generic argument(s) were provided. A generic argument must be provided for each generic parameter."} Can someone tell me what I'm doing wrong? Also

Fluent nhibernate automapping collection

二次信任 提交于 2019-12-06 11:14:06
问题 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{

AutoMapper - Why it is overwriting whole object? [duplicate]

余生长醉 提交于 2019-12-05 20:32:23
This question already has an answer here: Automapper: Update property values without creating a new object 3 answers I don't understand why it's overwriting my whole object. The reason is that I get my User object from db an I want to assign new values from DTO. Instead of just adding those new values it's creating new object that has new values but all previous are set to null . How can I make sure that in this case he will "upgrade" my object, not create new one? Scenario /users/{id} - PUT // User has id, username, fullname // UserPut has fullname public HttpResponseMessage Put(int id,

Fluent NHibernate: Mixing Automapping and manual mapping

廉价感情. 提交于 2019-12-05 04:15:56
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! 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()) .Where(type => type == typeof(Domain.Market.Share)) .Where(type => type == typeof(Domain.HR.Employee))); /