I see and I totally agree, thanks for your time On Nov 1, 8:38 pm, Asbjørn Ulsberg <asbjo...@gmail.com> wrote: > As far as I can understand, what you want is not component mapping. A > component will look like its own object in your domain model, but will be > stored along with the entity it's defined on, in the same table. > > So if you have a Person with an Address component, you'll have > AddressStreet, AddressCity, etc., columns in your Person table. Since what > you want is "implicit" columns, or "vertical" columns, you really need a > separate entity with its own table to store all those dynamic values. > > That other table could very well be "Detail" as you have mapped it now, > but it's not a component. You would need to "distillate" all values stored > in Details as properties on all subclasses of Item and ignore those > properties so NHibernate doesn't try to save them. > > You'd probably be wise to create a convention for all subclasses of Item > so they all map to the same Item table, since that's the only table you'd > need for this kind of dictionary-based property storage. > > -Asbjørn > > On Mon, 01 Nov 2010 20:27:58 +0100, marcus <mar...@meridium.se> wrote: > > In short my abstract Detail class looks like this > > > public abstract class Detail { > > [AutoMap] > > public virtual int Id { get; private set; } > > [AutoMap] > > public virtual string Name { get; set; } > > [AutoMap] > > public virtual string StringValue { get; set; } > > > public abstract object Value { get; set; } > > public abstract Type ValueType { get; } > > > public static Detail New(PageItem item, string name, object > > value) { > > var t = value.GetType(); > > if (t == typeof(string)) > > return new StringDetail(name, (string)value); > > return null; > > } > > > .. and my details is mapped like this > > > .Override<Item>(map => map.HasMany(x => > > x.Details).DictionaryKey("Name").OneToMany()) > > > Yes maybe that is one solution but I felt that the component map > > thingy almost works out of the box. > > > On Nov 1, 8:06 pm, Asbjørn Ulsberg <asbjo...@gmail.com> wrote: > >> How does the Detail class look like? Is it a mapped entity? How are you > >> mapping the Item.Details property? > > >> If you want Person.Address to just reflect the value of > >> Details["address"], you should just ignore the property in PersonMap > >> and instead implement it like this: > > >> public class Person : Item { > >> public virtual Address Address { > >> get { return new Address(Details["address"]); } > >> } > >> } > > >> -Asbjørn > > >> On Sun, 31 Oct 2010 23:52:34 +0100, marcus <mar...@meridium.se> wrote: > >> > A simplified view of my classes looks like this > > >> > public class Item { > >> > public virtual int? Id {get;set;} > >> > public virtual string Name {get;set;} > >> > public virtual IDictionary<string,Detail> Details {get;set;} > >> > public Item() { > >> > Details = new Dictionary<string,Detail>(); > >> > } > >> > } > > >> > Details is a dynamic way of adding properties to my entitys for > >> > instance if you in another class adds public virtual string Text > >> > {get;set;} i have an interceptor that fetches to value from the > >> > Details collection with the name Text. > >> > My Details is located in another table and one item can have many > >> > details of different types. > >> > Now I would like to have support for components in my entitys, so for > >> > instance if I create a new class that inherits Item > > >> > public class Person : Item { > >> > public virtual Address {get;set;} > >> > } > >> > public class Address { > >> > public virtual string Street {get;set;} > >> > } > > >> > so when I try the fetch the street property from my address component > >> > I would like to get the value from my Details collection or my Details > >> > table. Maybe this is not an FNH question or maybe it is? > > >> > On Oct 24, 4:37 am, Paul Batum <paul.ba...@gmail.com> wrote: > >> >> You are going to have to elaborate, because in most cases, > >> components >> are > >> >> used when you want some columns in the SAME table pushed down onto a > >> >> different object. I know there are exceptions to this but they are > >> >> obscure > >> >> enough that its hard to understand exactly what you are trying to do. > > >> >> On Sat, Oct 23, 2010 at 5:44 AM, marcus <mar...@meridium.se> wrote: > >> >> > Is it possible to automap components to another table? If so, how > >> can > >> >> > I do it? > > >> >> > -- > >> >> > You received this message because you are subscribed to the Google > >> >> Groups > >> >> > "Fluent NHibernate" group. > >> >> > To post to this group, send email to >> > >> fluent-nhibern...@googlegroups.com. > >> >> > To unsubscribe from this group, send email to > > >> fluent-nhibernate+unsubscr...@googlegroups.com<fluent-nhibernate%2Bunsubscr > >> > >> >> i...@googlegroups.com> > >> >> > . > >> >> > For more options, visit this group at > >> >> >http://groups.google.com/group/fluent-nhibernate?hl=en.
-- You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To post to this group, send email to fluent-nhibern...@googlegroups.com. To unsubscribe from this group, send email to fluent-nhibernate+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en.