Page 1 of 1
LinQ: Take TakeWhile
Posted: Thu 12 Apr 2012 20:26
by GeroL
Hi,
do the dotConnect any LinQ products from devart support these functions?
I always get a LinQ to SQL does not know function that exception.
Regards
Posted: Fri 13 Apr 2012 13:11
by MariiaI
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?