Home
About
Forum
Contact
Bugtracker
Download
Credits
Geek Shop
Guest
Log in
Register
Search
PUZZLE FORUMS
Forums
.
NPersist
.
Linq To NPersist
Register
Log in
Thread
Linq To NPersist
From:
Roger - Puzzle
- Posted: 2/13/2008 8:44:00 AM
Toggle helpful
Reply
Delete
Edit
We are currently working hard to get the Linq support finished.
Some of the features are already in place.
How to try the Linq support:
First include the
NPersist
.NET 3.5 project or binaries into your solution.
Then add the following line of code at the top of your consumer/test code:
using
Puzzle
.
NPersist
.
Framework;
(You most likely already have that if you are using the Context class)
Filter on property
var
result
=
from
customer
in
ctx
.
Repository
<
Customer
>
()
where
customer
.
Name
like
'
A%
'
select
customer;
Subquery on Order.Count
var
result
=
from
customer
in
ctx
.
Repository
<
Customer
>
()
where
customer
.
Name
like
'
A%
'
&&
customer
.
Orders
.
Count
>
10
select
customer;
Using load spans
var
result
=
from
customer
in
ctx
.
Repository(
new
LoadSpan
<
Customer
>
(
"
Name
"
,
"
Email
"
))
select
customer;
Complex subqueries
var
res
=
from
cust
in
ctx
.
Repository
<
Customer
>
()
where
(from
order
in
cust
.
Orders
where
order
.
OrderDate
=
=
new
DateTime(
2008
,
01
,
01
)
&&
order
.
Total
=
=
3
.
1
select
order)
.
Count
>
0
select
cust;
RE:Linq To NPersist
From:
Roger - Puzzle
- Posted: 2/13/2008 9:02:00 AM
Toggle helpful
Reply
Delete
Edit
Suggestions:
Patrik Löwendahl suggested a typed loadspan approach:
ctx
.
Repository
<
Customer
>
()
.
With(customer
=
>
new
{
customer
.
Email,
customer
.
Name
}
)
RE:Linq To NPersist
From:
Roger - Puzzle
- Posted: 2/20/2008 4:36:00 PM
Toggle helpful
Reply
Delete
Edit
I've added some more support today..
"Any"
var
res
=
from
cust
in
ctx
.
Repository
<
Customer
>
()
where
cust
.
Orders
.
Any(order
=
>
order
.
Total
>
10
)
select
cust;
"All"
var
res
=
from
cust
in
ctx
.
Repository
<
Customer
>
()
where
cust
.
Orders
.
All(order
=
>
order
.
Total
<
1000
)
select
cust;
"Contains"
var
res
=
from
cust
in
ctx
.
Repository
<
Customer
>
()
where
cust
.
Orders
.
Contains(someOrder)
select
cust;
Parameters
Customer
someCustomer
=
.
.
.
.
;
var
res
=
from
cust
in
ctx
.
Repository
<
Customer
>
()
where
cust
!
=
someCustomer
select
cust;