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