using System.Data.Entity; public class MyDBContext : DbContext { public DbSetProducts { get; set; } } var context = new MyDBContext(); var products = context.Products.ToList();
using System.Data.Entity; public class MyDBContext : DbContext { public DbSetProducts { get; set; } } var context = new MyDBContext(); var newProduct = new Product { Name = "New Product", Price = 50 }; context.Products.Add(newProduct); context.SaveChanges();
using System.Data.Entity; public class MyDBContext : DbContext { public DbSetThis example creates a new instance of MyDBContext and then calls a stored procedure called "GetProducts" in the database using context.Database.SqlQuery. It then returns the results as a list of Product objects. Package/library used: Entity Framework.Products { get; set; } } var context = new MyDBContext(); var products = context.Database.SqlQuery ("EXEC dbo.GetProducts");