示例#1
0
        public ActionResult Add(OrderViewModel req)
        {
            if (!ModelState.IsValid)
            {
                return(View(req));
            }

            VilinDBContext context = new VilinDBContext();
            OrderModel     ob      = new OrderModel();

            ob.OrderCode   = req.OrderCode;
            ob.ProductCode = req.ProductCode;
            context.Set <OrderModel>().Add(ob);
            context.SaveChanges();

            OrderModel ob1 = context.Set <OrderModel>().FirstOrDefault();

            return(View());
        }
示例#2
0
        public ActionResult Index()
        {
            VilinDBContext context = new VilinDBContext();

            //OrderModel ob = new OrderModel();
            //ob.OrderCode = "O" + DateTime.Now.ToString("mmsss") ;
            //ob.ProductCode = "CN001";
            //context.Set<OrderModel>().Add(ob);
            //context.SaveChanges();

            List <OrderModel> obs = context.Set <OrderModel>().Where(o => o.Id > 1).ToList();

            obs.FirstOrDefault();

            //IQueryable<OrderModel> obs = context.Set<OrderModel>().Where(o => o.Id > 3);
            //obs.FirstOrDefault();

            return(View());
        }
示例#3
0
 public Repository(VilinDBContext context)
 {
     //Guard.ArgumentNotNull(context, "context");
     this.DbContext = context;
     this.DbSet     = this.DbContext.Set <TEntity>();
 }