coalesce - SQL to LINQ Convertion -


this sql query:

select     s.student_no,     coalesce(p.name,'0'),    p.surname      person p  join     student s         on p.id = s.person_id 

i want convert linq , did except coalesce function,

from p in cbu.person join s in cbu.student on p.id equals s.person_id select new {      s.stundent_no,      p.name,      p.surname, }; 

how can use coalesce in linq query

thanks lot..

p.name ?? "0". c# has coalesce operator built-in. if didn't know that, use ?: operator.

the join not necessary, btw. can write p.student.stundent_no (or whatever properties called).


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -