public ActionResult Index() { AdventureWorks2017Entities ctx = new AdventureWorks2017Entities(); var products = ctx.Products.ToString(); return(View(products)); }
private void button1_Click(object sender, EventArgs e) { using (AdventureWorks2017Entities ctx = new AdventureWorks2017Entities()) { dataGridView1.AutoGenerateColumns = true; dataGridView1.DataSource = ctx.Person.ToList(); } }
protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { _adventureWorksContext = null; } // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below. // TODO: set large fields to null. disposedValue = true; } }
// GET: ShowTable public ActionResult Index() { var s_productid = (string.IsNullOrEmpty(Request["sproductid"]) ? "" : Request["sproductid"]); var s_name = string.IsNullOrEmpty(Request["sname"]) ? "" : Request["sname"]; var s_color = string.IsNullOrEmpty(Request["scolor"]) ? string.Empty : Request["scolor"]; var s_listprice = string.IsNullOrEmpty(Request["slistprice"]) ? "" : Request["slistprice"]; var ctx = new AdventureWorks2017Entities(); if (s_color == string.Empty) { var product = ctx.Products .Where(p => p.Name.Contains(s_name)) .Where(p => p.ProductID.ToString().Contains(s_productid)) .Where(p => p.ListPrice.ToString().Contains(s_listprice)) .OrderBy(p => p.ProductID) .ToList() ; TempData["sname"] = s_name; TempData["sproductid"] = s_productid; TempData["scolor"] = s_color; TempData["slistprice"] = s_listprice; return(View(product)); } else { var product = ctx.Products .Where(p => p.Name.Contains(s_name)) .Where(p => p.Color.Contains(s_color)) .Where(p => p.ProductID.ToString().Contains(s_productid)) .Where(p => p.ListPrice.ToString().Contains(s_listprice)) .OrderBy(p => p.ProductID) .ToList() ; return(View(product)); } }
public IntegrationTests() { _adventureWorksContext = new AdventureWorks2017Entities(ConfigurationManager.ConnectionStrings["AdventureWorks2017Entities"].ToString()); }
public UnitOfWork(AdventureWorks2017Entities dbContext) { _dbContext = dbContext; }
public AdventureWorks2017Entities Init() { return(dbContext ?? (dbContext = new AdventureWorks2017Entities())); }
public Repository(AdventureWorks2017Entities dbContext) { _dbContext = dbContext; }
public GenericRepository(AdventureWorks2017Entities context) { this.Context = context; this.DbSet = context.Set <TEntity>(); }
public PersonRepository(AdventureWorks2017Entities aw_context) { this._adventure = aw_context; }
public UnitOfWork() { _context = new AdventureWorks2017Entities(); }