Questions tagged [automapping]

The convention-based Auto Mapping feature of Fluent NHibernate. Not to be confused with AutoMapper, the convention-based object-to-object mapper.

251 questions
40
votes
6 answers

Override for fluent NHibernate for long text strings nvarchar(MAX) not nvarchar(255)

When ever you set a string value in fluent NHibernate it alwasy sets the DB vales to Nvarchar(255), I need to store quite a lot of long string which are based on user inputs and 255 is impractical. Just to add this is an issue with the automapper…
TheAlbear
  • 5,507
  • 8
  • 51
  • 84
27
votes
3 answers

Getting "unable to cast PersistentGenericSet to ISet" error

I get this error: Unable to cast object of type 'NHibernate.Collection.Generic.PersistentGenericSet1[IocWinFormTestEntities.People]' to type 'System.Collections.Generic.ISet1[IocWinFormTestEntities.People]'. The entity: public class…
danyolgiax
  • 12,798
  • 10
  • 65
  • 116
25
votes
4 answers

Eager Loading Using Fluent NHibernate/Nhibernate & Automapping

I have a requirement to load a complex object called Node...well its not that complex...it looks like follows:- A Node has a reference to EntityType which has a one to many with Property which in turn has a one to many with PorpertyListValue public…
nabeelfarid
  • 4,156
  • 5
  • 42
  • 60
21
votes
5 answers

Cascade Saves with Fluent NHibernate AutoMapping

How do I "turn on" cascading saves using AutoMap Persistence Model with Fluent NHibernate? As in: I Save the Person and the Arm should also be saved. Currently I get "object references an unsaved transient instance - save the transient instance…
rmontgomery429
  • 14,660
  • 17
  • 61
  • 66
12
votes
3 answers

Fluent NHIbernate automapping of List?

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…
Alex
  • 3,099
  • 6
  • 41
  • 56
10
votes
2 answers

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

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…
10
votes
1 answer

Fluent NHibernate JoinedSubClass is obsolete

I wonder about something. I'm sitting here with a solution there I have 1 superclass that has 2 subclasses and I'm currently mapping this using JoinedSubClass, but I get that this method is obsolete, and says that I should ClassMap and SubClassMap,…
10
votes
1 answer

Mapping multiple properties of a same type with HasMany via automapping

I am trying to map properties of the same type on a OneToMany association. I tried to distinguish with Description but kinda stuck here. public class User { public virtual int UserId { get; set; } public virtual string UserName { get; set;…
Mert
  • 6,432
  • 6
  • 32
  • 68
10
votes
5 answers

Generate C# entities from existing DB and Fluent NHibernate auto mapping

I'm working with an existing database that uses some really ugly conventions. I'd like to use NHibernate, and I think I can fix all these ugly DB conventions using Fluent NHibernate's auto mapping conventions. I'd like to avoid writing all the…
Lance Fisher
  • 25,684
  • 22
  • 96
  • 122
8
votes
5 answers

Jquery post to Action with Dictionary Parameter

I am feeling dejavu, but I cannot find the answer to this: I have an array of objects that needs to look like this when inspecting a jQ $.post call: limiter[0].Key limiter[0].Value so that it is mapped in the action public ActionResult…
Bill Bonar
  • 1,017
  • 2
  • 10
  • 22
8
votes
5 answers

Fluent Nhibernate Automap convention for not-null field

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 {…
Robi
  • 287
  • 4
  • 11
8
votes
10 answers

C# - IDataReader to Object mapping using generics

How can I map a DataReader object into a class object by using generics? For example I need to do the following: public class Mapper { public static List MapObject(IDataReader dr) { List objects = new…
user366312
  • 16,949
  • 65
  • 235
  • 452
7
votes
1 answer

Fluent NHibernate Automapping with abstract base class

Given the classes below: public class Address : Place { public virtual string Street { get; set; } public virtual int Number { get; set; } public override string WhereAmI { get { string.Format("{0} {1}", Street , Number);…
amaters
  • 2,266
  • 2
  • 24
  • 44
7
votes
1 answer

Fluent NHibernate: Mixing Automapping and manual mapping

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…
LondonPhantom
  • 1,867
  • 3
  • 19
  • 26
6
votes
2 answers

FluentNHibernate: Automapping OneToMany relation using attribute and convention

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; } …
user593358
1
2 3
16 17