c# LINQ: how to retrieve a single result

后端 未结 8 1434
梦如初夏
梦如初夏 2020-12-29 07:00

Kind of new to linq,

whats the simplest way to retrieve a single result using linq?

example, my query

var query =
     from c in db.productIn         


        
8条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-29 07:10

    string str = (
      from c in db.productInfo 
      where c.flavor == "Classic Coke" && c.container == "Can"
      select c.co2Target)
        .Single().columnName;
    

提交回复
热议问题