In this post we will see Lambda Expression Queries
1. Normal Select Query
var result = dbcontext.table_name.ToList();
2. Select particular columns
var result = dbcontext.table_name.select(x => new { AsColumnName = x.ColumnName, AsColumnName = x.ColumnName });
3. Select Top 10 Records from the table
var result = dbcontext.table_name.Take(10).ToList();
4. Order By Query using Lambda Expression
var result = dbcontext.table_name.OrderBy(x => x.columnName).ToList();
5. Order By Descending
var result = dbcontext.table_name.OrderByDescending(x => x.columnName).ToList();
1. Normal Select Query
var result = dbcontext.table_name.ToList();
2. Select particular columns
var result = dbcontext.table_name.select(x => new { AsColumnName = x.ColumnName, AsColumnName = x.ColumnName });
3. Select Top 10 Records from the table
var result = dbcontext.table_name.Take(10).ToList();
4. Order By Query using Lambda Expression
var result = dbcontext.table_name.OrderBy(x => x.columnName).ToList();
5. Order By Descending
var result = dbcontext.table_name.OrderByDescending(x => x.columnName).ToList();
No comments:
Post a Comment