automapping

How to automap Table-per-class heirarchy in S#arp architecture

Hi, I am pretty new to S#harp architecture and fluent nhibernate. I was trying to build a sample solution using the template. MappingIntegrationTest fails for me when I try to run it for the following domains public class Component { public virtual string comp { get; set; } } public class Parent : Entity { public virtual string Ty...

How to map part of aspnet_Users table using Fluent NHibernate

I'm trying to get Fluent NHibernate 1.0 RTM to map a User entity for me so that I have access to UserId and UserName inside my ASP.NET MVC application via NHibernate. I have: public class User { public virtual Guid UserId { get; protected set; } public virtual string UserName { get; protected set; } } It represents the aspnet...

How do I map Join tables with fluent auto mapping?

Here are my classes: public abstract class TypeBase { public virtual int? Id { get; set; } public virtual string Name { get; set; } } // various other classes extend TypeBase the same way public class Color : TypeBase { } public class Template { public virtual int? Id { get; set; } public virtual IList<Style...

Why does AutoMapper have an IValueFormatter when it has a seemingly much more powerful ValueResolver?

It looks like an IValueFormatter takes a value of type object and returns a value of type string, while a ValueResolver<TSource, TDestination> takes a value of any type and returns a value of any type. So, it's more flexible. There is also the matter that, with a ValueResolver, you never need to cast the source to a particular type--you ...

fluent nhibernate automap version column

Current code in my convention: public void Apply(FluentNHibernate.Conventions.Instances.IVersionInstance instance) { instance.Column("RowVersion"); instance.Not.Nullable(); instance.UnsavedValue("0"); instance.Default(1); } This doesn't render the RowVersion as a version column. It treats Ro...

AutoMapper converters fail for null values

Problem: I have an AutoMapper converter that takes a Nullable<bool>/bool? and returns a string. I apply this globally to my profile, and it works for true and false but not for null. Here is what I have in my AutoMapper profile: CreateMap<bool?, string>() .ConvertUsing<NullableBoolToLabel>(); And here is the converter class: pu...

fluent nhibernate: INSERT error when saving a new entity with a child entity

I am trying to save a new entity 'Post' with 1 item added to its 'Revisions' List. A 'Post' can has many PostRevisions, and a PostRevision can only have one Post I have tried several ways of mapping the PostRevisions, my PostRevisionMap is as follows: public PostRevisionMap() { Id(x => x.PostRevisionId, "PostRevisionId");...

Can't figure out what the other side of the many-to-many property 'Users' should be.

My Domain auto mapping was working but now as I updated my NHibernate stack I'm getting mapping exception when Session Factory is building the Configuration: "Can't figure out what the other side of the many-to-many property 'Users' should be." The exception is thrown on a many to many map The whole stack trace is this o...

Fluent NHibernate automapper: skip an intermediate class w/ table-per-subclass

I'm using the Fluent NHibernate mapper with table-per-subclass to map the following structure: public abstract class A { // properties here } public abstract class B : A { // methods here } public class C : B { // properties here } My database only has tables to represent class A and class C. Class B exists only in my mo...

Fluent NHibernate and computed properties

I'm using Fluent NHibernate, and auto-mapping the classes. I have a computed property in a class along the lines of public virtual DateTime? LastActionTimeStamp { get { return Actions.Count == 0 null : Actions.OrderByDescending( a => a.TimeStamp).ElementAt(0).TimeStamp; } } This wasn't mapped with the rest...

Getting error "Association references unmapped class" when using interfaces in model

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...

Merge two objects to produce third using AutoMapper

I know it's AutoMapper and not AutoMerge(r), but... I've started using AutoMapper and have a need to Map A -> B, and to add some properties from C so that B become a kind of flat composite of A + C. Is this possible in AutoMapper of should I just use AutoMapper to do the heavy lifting then manually map on the extra properties? ...

Automapper -cannot resolve the Generic List

Mapper.CreateMap<BusinessObject, Proxy.DataContacts.DCObject>() .ForMember(x => x.ExtensionData, y => y.Ignore()) .ForMember(z => z.ValidPlaces, a=> a.ResolveUsing(typeof(ValidPlaces))); Mapper.AssertConfigurationIsValid(); proxydcObject = Mapper.Map<BusinessObject, Proxy.DataContracts.DCObject>(_instanceOfBusinessObject); //thro...

Automapping doesn't have an Id mapped

My Entity Class: public class Building { /// /// internal Id /// public virtual long Id { get; set; } .............. } My Mapping: var model = AutoMap.AssemblyOf() .Setup(s => s.FindIdentity = p => p.Name == "Id") .Where(t => t.Namespace == "SpikeAu...

FluentNHibernate Overrides: UseOverridesFromAssemblyOf non-generic version

Hi, I have a repository class that inherits from a generic implementation: public namespace RepositoryImplementation { public class PersonRepository : Web.Generics.GenericNHibernateRepository<Person> } The generic repository implementation uses Fluent NHibernate conventions. They're working fine. One of those conventions is that ...

Fluent Nhibernate Automap convention for not-null field

Hi, Could some one help, how would I instruct automap to have not-null for a cloumn? public class Paper : Entity { public Paper() { } [DomainSignature] [NotNull, NotEmpty] public virtual string ReferenceNumber { get; set; } [NotNull] public virtual Int32 SessionWeek { get...

Fluent NHibernate ModifiedDate Version Convention

Hi, I am trying to create a fluent Nhibernate automap convention for all the modifiedDate property of my application where it should set the value to get the current date during UPDATE. I am trying the following and its not working. I want the SQL server to update the date. Please advice. public class ModifiedDateVersionConvention : IVe...

What is the best way to provide an AutoMappingOverride for an interface in fluentnhibernate automapper

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 N...

Automapper failing to map on IEnumerable

I have two classes like so: public class SentEmailAttachment : ISentEmailAttachment { public SentEmailAttachment(); public string FileName { get; set; } public string ID { get; set; } public string SentEmailID { get; set; } public string StorageService { get; set; } public string StorageServiceFileID { get; set;...

Map derived class as an independent one with FNH's Automap

Hi! Basically, I have an ImageMetadata class and an Image class, which derives from ImageMetadata. Image adds one property: byte[] Content, which actually contains binary data. What I want to do is to map these two classes onto one table, but I absolutely do not need NHibernates' inheritance support to kick in. I want to tailor FNH Aut...