Not only is it a good workaround, but I'd say it'd the preferred solution.
If the (name of the) type really has relevance, it deserves a property.

/G

2011/8/29 [email protected] <[email protected]>

> There would have to be an additional nhlinq function to accomplish
> this & at current, there isn't.  A super easy workaround is to just
> map the discriminator as a readonly property and select that property
> directly.
>                cm.Property(x => x.DiscrimType, x => {
>                    x.Column("DiscriminatorType");
>                    x.Insert(false);
>                    x.Update(false);
>                });
>
> On Aug 27, 1:24 am, Richard Wilde <[email protected]> wrote:
> > When projecting a discriminator column into a DTO using QueryOver I
> > can do the following:-
> >
> > return Session
> >   .QueryOver<Product>()
> >   .SelectList(i => i
> >     .Select(p => p.Name).WithAlias(() => dto.Name)
> >     .Select(p => p.GetType()).WithAlias(() => dto.ProductType)
> >   )
> >   .TransformUsing(Transformers.AliasToBean<ProductDto>())
> >   .List&lt;ProductDto>();
> >
> > However when using Linq I can't seem to get the discriminator value
> > only the derived class name.
> >
> > return (from product in Session.Query<Product>()
> >   select new ProductDto{
> >     Name = product.Name,
> >     ProductType = product.GetType().Name
> >
> > }).ToList();
> >
> > Here GetType().Name returns the derived class name (as one would
> > expect), how do I get the discriminator value using Linq?
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" 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/nhusers?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" 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/nhusers?hl=en.

Reply via email to