Helo,
when i have CriteriaAPI:
 public class ProductDescriptionDto
        {
            public string ProductName { get; set; }
            public decimal ProductsPrice { get; set; }
        }

 IProjection roundSqlProjection =
Projections.SqlProjection(@"round(UnitPrice * UnitsInStock, -2) as
ProductsPrice",
                                                new string[]
{ "ProductsPrice" },
                                                new IType[]
{ NHibernateUtil.Decimal });

            this.Session.CreateCriteria(typeof(Product))
               .SetProjection(Projections.ProjectionList()
                               
.Add(Projections.Property("Name").As("ProductName"))
                               .Add(roundSqlProjection))
               
.SetResultTransformer(Transformers.AliasToBean(typeof(ProductDescriptionDto)))
               .List<ProductDescriptionDto>();
it does what it deos.
I wanted to make it work under QueryOver. I tired but ther eis not
such "SelectSqlProjection" or something in the Selectlist builder.

It tried like this below but it gives me an error:
 Unrecognised method call in epression
Round((x.UnitPrice.GetValueOrDefault() * Convert(x.UnitsInStock))).

And the query goes like this:
 this.Session.QueryOver<Product>()
                .SelectList(builder => builder
                    .Select(x => x.Name).WithAlias(() =>
dtoAlias.ProductName)
                    .Select(x =>
Math.Round(x.UnitPrice.GetValueOrDefault() *
x.UnitsInStock)).WithAlias(() => dtoAlias.ProductsPrice))
                
.TransformUsing(Transformers.AliasToBean(typeof(ProductDescriptionDto)))
                .List<ProductDescriptionDto>();

Is there support for SqlProjections in QueryOver or workaround for
this?

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