Linq to SQL Select inside Join

Berikut contoh query Linq dengan select di dalam join table

[code language=”csharp”]
int count = (
from permit in db.permit_to_work
join log in
(
from log in db.permit_log.Where(m => m.permit_type == 0 && m.status == queryStatus && m.user_id == UserId)
.GroupBy(m => m.id_permit)
select new { id_permit = log.Key, maxdt = log.Max(m => m.datetime) }
) on permit.id equals log.id_permit
where permit.acc_ptw_requestor == strUserId && permit.validity_period_end <= log.maxdt
select permit.id
).Count();
[/code]

Referensi http://stackoverflow.com/questions/19786382/linq-to-sql-select-inside-an-inner-join

Chandra Oemaryadi has written 244 articles

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>