asp.net - How to convert the sql statement to linq (VB) -


the following sql statement works fine, how can convert linq (vb) ?

i had looked online tools, doesn't work...

thanks

select distinct a.sid, a.displayname,      case when b.sid not null 1 else 0 end type1,     case when c.sid not null 1 else 0 end type2,     case when d.sid not null 1 else 0 end type3 dbo.vhris_emailalert left join dbo.vhris_emailalert b on a.sid = b.sid , b.type = 4 left join dbo.vhris_emailalert c on a.sid = c.sid , c.type = 5 left join dbo.vhris_emailalert d on a.sid = d.sid , d.type = 6  a.cid=37 , (b.type=4 or c.type=5 or d.type=6)  

the following linq. run linq linqpad, returns "syntax error"

(from in db.vhris_emailalerts _ group join b in db.vhris_emailalerts _       on new { a.sid, .type = 4 } _   equals new { b.sid, .type = ctype(clng(b.type),int64?) } b_join = group _ b in b_join.defaultifempty() _ group join c in db.vhris_emailalerts _       on new { a.sid, .type = 5 } _   equals new { c.sid, .type = ctype(clng(c.type),int64?) } c_join = group _ c in c_join.defaultifempty() _ group join d in db.vhris_emailalerts _       on new { a.sid, .type = 6 } _   equals new { d.sid, .type = ctype(clng(d.type),int64?) } d_join = group _ d in d_join.defaultifempty() _ _   clng(a.cid) = 37 , _   (clng(b.type) = 4 or _   clng(c.type) = 5 or _   clng(d.type) = 6) _ select  _   sid = ctype(a.sid,int32?), _   a.displayname, _   type1 = if( _   not b.sid nothing, 1, 0), _   type2 = if( _   not c.sid nothing, 1, 0), _   type3 = if( _   not d.sid nothing, 1, 0)) _ ).distinct.tolist 

it's complicated convert linq. create view instead of using linq


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -