The below code will explain the simple LINQ Query with
multiple select column name. Here I used
to filter records from lstValue with ID have “100”. The filter Linq Query will return the ID and
Name values only. It will omit the Class in the result.
public class KeyValue
{
public string ID { get; set; }
public string Name { get; set; }
public string Class { get; set; }
}
//Declaration of KeyValue Class
public List<KeyValue> lstValue { get; set; }
// Filter in LINQ Query
var Result = lstValue.Select(c => new { c.ID, c. Name, c.Class });
var result = from a in lstValue
where a.ID == "100"
select new { a.ID, a.Name };
Assign the Generic List values to asp.net grid view.
//grdDetails – Datagrid (Assign the
value to Grid)
grdDetails.DataSource = result.ToList();
No comments:
Post a Comment