-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestingLinqKit.linq
35 lines (32 loc) · 1.16 KB
/
TestingLinqKit.linq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<Query Kind="Program">
<Connection>
<ID>54bf9502-9daf-4093-88e8-7177c12aaaaa</ID>
<NamingService>2</NamingService>
<Persist>true</Persist>
<Driver Assembly="(internal)" PublicKeyToken="no-strong-name">LINQPad.Drivers.EFCore.DynamicDriver</Driver>
<AttachFileName><ApplicationData>\LINQPad\ChinookDemoDb.sqlite</AttachFileName>
<DisplayName>Demo database (SQLite)</DisplayName>
<DriverData>
<PreserveNumeric1>true</PreserveNumeric1>
<EFProvider>Microsoft.EntityFrameworkCore.Sqlite</EFProvider>
<MapSQLiteDateTimes>true</MapSQLiteDateTimes>
<MapSQLiteBooleans>true</MapSQLiteBooleans>
</DriverData>
</Connection>
<NuGetReference>LinqKit.Core</NuGetReference>
<Namespace>LinqKit.Core</Namespace>
<IncludeLinqToSql>true</IncludeLinqToSql>
</Query>
void Main()
{
var over20 = QueryCustomers(this, x => x.Total > 20.0F);
over20.Dump();
}
static IEnumerable<string> QueryCustomers(UserQuery db, Expression<Func<Invoice, bool>> invoiceCriteria)
{
var query =
from c in db.Customers.AsExpandable()
where c.Invoices.Any(invoiceCriteria.Compile())
select $"{c.FirstName} {c.LastName}";
return query.ToArray();
}