Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Get Values from single column based on condition

I am New to C# LINQ. 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#

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

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

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading