LinQ: Take TakeWhile

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
Posts: 4
Joined: Wed 11 Apr 2012 23:31

LinQ: Take TakeWhile

Post by GeroL » Thu 12 Apr 2012 20:26


do the dotConnect any LinQ products from devart support these functions?
I always get a LinQ to SQL does not know function that exception. :(


Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Post by MariiaI » Fri 13 Apr 2012 13:11

TakeWhile is a Linq to Objects method, and is not supported in LinqConnect (or LINQ to SQL), as it cannot be converted into any valid SQL.
However, you can get a wider result set into the memory and use TakeWhile on it.
You could try using:

Code: Select all

YourDataContext dc = new YourDataContext();
var q = (from c in dc.Customers.AsEnumerable()
select c).TakeWhile(c => c.City != string.Empty);
By adding the AsEnumerable(), the entire table is brought into memory. The TakeWhile can then be done in memory and not as part of the SQL Statement.

J.C.: The method "Take" is supported by Devart products. If you encounter any problems with it, could you please describe the situation in which they occur?

Post Reply