Exemplo n.º 1
0
        public ActionResult Index()
        {
            AdventureWorks2017Entities ctx = new AdventureWorks2017Entities();
            var products = ctx.Products.ToString();

            return(View(products));
        }
Exemplo n.º 2
0
 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;
            }
        }
Exemplo n.º 4
0
        // 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());
 }
Exemplo n.º 6
0
 public UnitOfWork(AdventureWorks2017Entities dbContext)
 {
     _dbContext = dbContext;
 }
Exemplo n.º 7
0
 public AdventureWorks2017Entities Init()
 {
     return(dbContext ?? (dbContext = new AdventureWorks2017Entities()));
 }
Exemplo n.º 8
0
 public Repository(AdventureWorks2017Entities dbContext)
 {
     _dbContext = dbContext;
 }
Exemplo n.º 9
0
 public GenericRepository(AdventureWorks2017Entities context)
 {
     this.Context = context;
     this.DbSet   = context.Set <TEntity>();
 }
Exemplo n.º 10
0
 public PersonRepository(AdventureWorks2017Entities aw_context)
 {
     this._adventure = aw_context;
 }
Exemplo n.º 11
0
 public UnitOfWork()
 {
     _context = new AdventureWorks2017Entities();
 }