Hello Guys, I have a linq query with NHibernate using Session.Query<T> method and I in this query I Fetch some complex properties and collection properties. I would like to know, how cna I add an condition with IN operator from an int[] ? Look my code:public IEnumerable<Product> GetProducts(int[] idCategories){// how to add IN condition here or a subqueryvar query = Session.Query<Product>().Where(?????).Fetch(x=>xCategory).FetchMany(x=>x.Status).ThenFetch(x=>x.Item);return query.ToList();}I have another method doing a query to get this int[] and I would like to apply it here, or if is there any way to add this subquery on the IN operator, I really appreciate!Thank you!--______________________________________
Felipe B. Oriani
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/Hqr2JRy-dmYJ.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
Hi misterd429,
I could convert int[] ni List<int> without problem. THis way using .Contains(id) will generate a IN operator ?Thank you!
On Tue, Jul 17, 2012 at 10:34 AM, mysterd429 <> wrote:
Felipe,
I'd do something like .Where(p => idCategories.Contains(p.IdCategory)), but I find it is sometimes finicky about the type. I use List<int> without a problem.
Don
On Monday, July 16, 2012 10:50:09 PM UTC-4, Felipe Oriani wrote:Hello Guys, I have a linq query with NHibernate using Session.Query<T> method and I in this query I Fetch some complex properties and collection properties. I would like to know, how cna I add an condition with IN operator from an int[] ? Look my code:public IEnumerable<Product> GetProducts(int[] idCategories){// how to add IN condition here or a subqueryvar query = Session.Query<Product>().Where(?????).Fetch(x=>xCategory).FetchMany(x=>x.Status).ThenFetch(x=>x.Item);return query.ToList();}I have another method doing a query to get this int[] and I would like to apply it here, or if is there any way to add this subquery on the IN operator, I really appreciate!Thank you!--______________________________________
Felipe B. Oriani"...Trabalhe quanto puder, tornando-se útil quanto possível..." , por André Luiz
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/Hqr2JRy-dmYJ.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
IEnumerable<Int32> someIntegers = Enumerable.Range(1, 100).Where(i => i % 2 == 0 || i % 5 == 0); // Just some arbitrary numbers
session.Query<MyEntityType>().Where(et => someIntegers.Contains(et.Id));
To view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/3nhQ2HsR7XcJ.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
var subQuery = QueryOver.Of<Category>()
.Where(c => /* condition here */ && /* another condition here */ && /* another condition here too */)
.Select(Projections.Id());
Product productAlias = null;
Supplier supplierAlias = null;
Order orderAlias = null;
OrderRow orderRowAlias = null;
var result = Session.QueryOver(() => productAlias)
.Left.JoinAlias(() => productAlias.Supplier, () => supplierAlias)
.Left.JoinAlias(() => productAlias.Order, () => orderAlias)
.Left.JoinAlias(() => orderAlias.OrderRow, () => orderRowAlias)
.WithSubquery.WhereProperty(() => productAlias.Category.Id).In(subQuery)
.OrderBy(() => productAlias.Name).Desc
.TransformUsing(Transformers.DistinctRootEntity)
.List();
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/v2l6mLTNlsQJ.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
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 view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/l5XSTo69quwJ.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
How about if you do it all with QueryOver, since I believe it's still not possible to do subqueries using the linq provider, but I could be mistaken...