public static void LinqToEntity() { ProductDBContext context = new ProductDBContext(); var EconProducts = from product in context.Products where product.Price < 50.00 select product; foreach (var product in EconProducts) { Console.WriteLine("ProductID: {0}, Name: {1},Price:{2}", product.ProductID, product.Name, product.Price); } }
static void Main(string[] args) { ProductDBContext context = new ProductDBContext(); var product = context.Products; var product1 = context.Products.Add(new Product() { ProductID = 1, Name = "badam Drink", Price = 99.99, Quantity = "500 ml", CategoryID = 1 }); var product2 = context.Products.Add(new Product() { ProductID = 2, Name = "Coffe Drink", Price = 59.99, Quantity = "250 ml", CategoryID = 1 }); var product3 = context.Products.Add(new Product() { ProductID = 3, Name = "Coke Drink", Price = 49.99, Quantity = "200 ml", CategoryID = 1 }); var categories = context.Categories; var category1 = categories.Add(new Category() { CategoryID = 1, Name = " Beverages", }); LinqToEntity(); context.SaveChanges(); }