How can I get particular value when I use LINQ where condition

Using LINQ query, how can I get particular record value?

public IEnumerable<EMS_USER_MASTER> HrEmails() 
    var xx= from cust in db.EMS_USER_MASTER
            where cust.ROLE_ID == 17

    foreach (var x in xx)
        var emailsList = new EmailTypes
            Hr_Email= x.Hr_Email
    return queryHrExeEmail.ToList();

From the above code I need only email column; how can I filter generally SQL query we write as

Select Email from TableName where n.UserUd=10

1 answer

  • answered 2018-10-23 04:59 Sham

    You can utilize Where method to filter records and Select method for selection.

    TableName.Where(x => x.UserUd == 10).Select(x => x.Email);