Hey frnds
i want to generate a Sr. No. in grid of all The Records using linq to sql query..
i have done this thing in Sql Query but i want to do it with linq..
select
ROW_NUMBER() Over (Order by SID) As [S.N.], [ProductBrand],[ProductModel]
[Type]
from stock where stockStatus='YES'
please make the linq query of above query..

Khan Abrar AhmedPosted Jun 2, 2014, 7:41 AM
var query = from s in stock
where s.stockStatus=="YES"
select new
{
ProductBrand = s.ProductBrand,
ProductModel = s.ProductModel,
Type=s.Type
};
return query.AsEnumerable() // Client-side from here on
.Select((stock, index) => new stock()
{
ProductBrand = s.ProductBrand,
ProductModel = s.ProductModel,
Type=s.Type,
RowNumber = index + 1;
}
.ToList();