public void GetInterface() { IEnumerable _data = null; _data.GetType(); NORTHWINDEntities db = new NORTHWINDEntities(); var records = (from o in db.Orders select o).AsEnumerable(); ImageContext image = new ImageContext(); for (int i = 0; i <= 100; i++) { image.Images.Add(new ImageModel() { Id = int.MinValue }); } IEnumerable<ImageModel> img = (from r in image.Images where r != null select r).AsEnumerable(); Assert.IsNotNull(img); }
public void CascadeUpdate() { var connectionString = ConfigurationManager.ConnectionStrings["NORTHWINDEntities"].ConnectionString; SqlConnection conn = new SqlConnection(connectionString); conn.Open(); //SqlCommand command = new SqlCommand("SELECT * FROM information_schema.tables", conn); SqlCommand command = new SqlCommand("SELECT *", conn); SqlDataAdapter adapter = new SqlDataAdapter(command); DataSet ds = new DataSet(); //DataTable dtOrders = adapter.Fill(ds.Tables["Orders"]); //DataTable dtOrderDetail = adapter.Fill(ds.Tables["Order_Details"]); //Select DB Objects //SELECT sobjects.name //FROM sysobjects sobjects //WHERE sobjects.xtype = 'U' //Here is a list of other object types you can search for as well: //C: Check constraint //D: Default constraint //F: Foreign Key constraint //L: Log //P: Stored procedure //PK: Primary Key constraint //RF: Replication Filter stored procedure //S: System table //TR: Trigger //U: User table //UQ: Unique constraint //V: View //X: Extended stored procedure using(var context = new NorthwindEntityContext.NORTHWINDEntities()){ //var da = DataAccess(); for (int i = 0; i < 125; i++) { context.Orders.Add(new Order() { OrderID = i }); } for (int i = 0; i < 125; i++) { context.Order_Details.Add(new Order_Detail() { OrderID = i }); } //var query = from o in context.Orders // from c in context.Customers.Where(c => c.CustomerID == o.CustomerID).DefaultIfEmpty() // from d in context.Order_Details.Where(d => d.OrderID == o.OrderID).DefaultIfEmpty() // group new { o, c, d } by new { o.OrderDate.Value.Year, c.CompanyName } into g // select new { // Company = g.Key.CompanyName, // OrderYear = g.Key.Year, // Amount = g.Sum(e => e.d.UnitPrice * e.d.Quantity) // }; } NORTHWINDEntities north = new NORTHWINDEntities(); var query = from o in north.Orders from c in north.Customers.Where(c => c.CustomerID == o.CustomerID).DefaultIfEmpty() from d in north.Order_Details.Where(d => d.OrderID == o.OrderID).DefaultIfEmpty() group new { o, c, d } by new { o.OrderDate.Value.Year, c.CompanyName } into g select new { Company = g.Key.CompanyName, OrderYear = g.Key.Year, Amount = g.Sum(e => e.d.UnitPrice * e.d.Quantity) }; NORTHWINDEntities db = new NORTHWINDEntities(); for (int i = 0; i < 125; i++) { db.Orders.Add(new Order() { OrderID = i}); } for (int i = 0; i < 125; i++) { db.Order_Details.Add(new Order_Detail() { OrderID = i}); } //select record(s) var record = from r in db.Orders join d in db.Order_Details on r.OrderID equals d.OrderID select r; string rec = ""; Assert.IsTrue(true); }
public void DataObject() { NORTHWINDEntities db = new NORTHWINDEntities(); var records = (from o in db.Orders select o).AsEnumerable(); //db.Orders(); //Moq.Linq(); ImageContext image = new ImageContext(); for (int i = 0; i <= 100; i++) { image.Images.Add(new ImageModel() { Id = int.MinValue }); } IEnumerable<ImageModel> img = (from r in image.Images where r != null select r).AsEnumerable(); //var ll = new LazyLoader; //LazyLoader; //Moq.Linq(img); //img.Cast<ImagesDBContext>(image)(img); Assert.IsNotNull(image); }