Marcus,

This is not germane to your original question, but...

What is the [AutoMap] attribute you are using?  That's not part of
Fluent NHibernate, is it?

-Tom

On Nov 1, 3:27 pm, marcus <[email protected]> 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 <[email protected]> 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 <[email protected]> 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 <[email protected]> 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 <[email protected]> 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  
> > >> [email protected].
> > >> > To unsubscribe from this group, send email to
>
> > >> [email protected]<fluent-nhibernate%2Bunsubscr
> > >>   
> > >> [email protected]>
> > >> > .
> > >> > For more options, visit this group at
> > >> >http://groups.google.com/group/fluent-nhibernate?hl=en.- Hide quoted 
> > >> >text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.

Reply via email to