Horje
Selecting multiple columns with linq query and lambda expression Code Example
Selecting multiple columns with linq query and lambda expression
public NamePriceModel[] AllProducts()
{
    try
    {
        using (UserDataDataContext db = new UserDataDataContext())
        {
            return db.mrobProducts
                .Where(x => x.Status == 1)
                .Select(x => new NamePriceModel { 
                    Name = x.Name, 
                    Id = x.Id, 
                    Price = x.Price
                })
                .OrderBy(x => x.Id)
                .ToArray();
         }
     }
     catch
     {
         return null;
     }
 }

public class NamePriceModel 
{
    public string Name {get; set;}
    public decimal? Price {get; set;}
    public int Id {get; set;}
}




Csharp

Related
C# creating a hashtable linked list Code Example C# creating a hashtable linked list Code Example
c# mapper.map Code Example c# mapper.map Code Example
c# .net RemoveClaim auth Code Example c# .net RemoveClaim auth Code Example
join where order by .net framework Code Example join where order by .net framework Code Example
facing issue of phone number in csv file c# Code Example facing issue of phone number in csv file c# Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10