You can use:
public YourClass[] AllProducts()
{
try
{
using (UserDataDataContext db = new UserDataDataContext())
{
return db.mrobProducts.Where(x => x.Status == 1)
.OrderBy(x => x.ID)
.Select(x => new YourClass { ID = x.ID, Name = x.Name, Price = x.Price})
.ToArray();
}
}
catch
{
return null;
}
}
And here is YourClass
implementation:
public class YourClass
{
public string Name {get; set;}
public int ID {get; set;}
public int Price {get; set;}
}
And your AllProducts
method's return type must be YourClass[]
.