LinQ: Take TakeWhile

LinQ: Take TakeWhile

Postby GeroL » Thu 12 Apr 2012 20:26

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
GeroL
 
Posts: 4
Joined: Wed 11 Apr 2012 23:31

Postby 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?
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17


Return to LinqConnect (LINQ to SQL support)