Home > front end >  Get Values from single column based on condition
Get Values from single column based on condition

Time:04-24

I have query and I can display values based on condition in SQL. But how can write C# LINQ query is my question.

SELECT Value 
FROM db.table 
WHERE xxId = 1 AND YYid = 2 AND IsActive = '1' AND IsDeleted = '0'

Result

NNNN
MMMM
TTTT
VVVV
LLLL

I need same query in LINQ C#

var results = db.table
                .Select(a => a.xxid == xxid && a.yyid == id && 
                             a.IsActive && !a.IsDeleted).value;

CodePudding user response:

var results = db.table
             .Where(a => a.xxid == xxid && a.yyid == id && a.IsActive && !a.IsDeleted)
             .Select(a => a.value)
             .ToList();
  • Related