简体   繁体   中英

SQL query on Entity Framework

How do I do this sql query to entity framework?

select 
id,
column1,
column2 =  case when (select max(column2) from table1 b where b.id = a.id) = a.column2 
then 'Positive' else 'Negative' end
from table1 a
var query = from t in context.table1
            let column2_temp = context.table1.Where(p=>p.id==t.id).Max(p=>p.column2)
            let column2 = column2_temp == t.column2? "Positive" : "Negative"
            select new {t.id, column2}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM