Exemplo n.º 1
0
 public Catalog AddIfNoExist(Catalog entity)
 {
     using (DbContext db = new SpiderContext())
     {
         var findEntity = db.Set <Catalog>().Where(o => o.RID == entity.RID).FirstOrDefault();
         if (findEntity != null)
         {
             return(findEntity);
         }
         entity.ID = Guid.NewGuid().ToString().ToUpper();
         db.Set <Catalog>().Add(entity);
         Save(db);
         return(entity);
     }
 }
Exemplo n.º 2
0
 public Catalog AddIfNoExist(Catalog entity)
 {
     using (DbContext db = new SpiderContext())
     {
         var findEntity = db.Set <Catalog>().Where(o => o.CatalogLink == entity.CatalogLink).FirstOrDefault();
         if (findEntity != null)
         {
             return(findEntity);
         }
         entity.ID         = Guid.NewGuid();
         entity.CreateTime = DateTime.Now;
         db.Set <Catalog>().Add(entity);
         Save(db);
         return(entity);
     }
 }
Exemplo n.º 3
0
 public void Add(T entity)
 {
     using (DbContext Context = new SpiderContext())
     {
         Context.Set <T>().Add(entity);
         Save(Context);
     }
 }
Exemplo n.º 4
0
 public bool TodayIsGetProduct(string RefCatalogLink)
 {
     using (DbContext Context = new SpiderContext())
     {
         string rankTime = DateTime.Now.ToString("yyyy-MM-dd");
         return(Context.Set <Catalog>().Count(o => o.CatalogLink == RefCatalogLink && o.RankTime == rankTime) > 0);
     }
 }
Exemplo n.º 5
0
 public void AddRange(List <Product> list)
 {
     using (DbContext Context = new SpiderContext())
     {
         list.ForEach(l =>
         {
             l.ID = Guid.NewGuid().ToString().ToUpper();
         });
         Context.Set <Product>().AddRange(list);
         Save(Context);
     }
 }
Exemplo n.º 6
0
 public void AddRange(List <Product> list)
 {
     using (DbContext Context = new SpiderContext())
     {
         DbSet <Product> dbSetEntity = Context.Set <Product>();
         Product         first       = list[0];
         list.ForEach(l =>
         {
             l.ID = Guid.NewGuid();
         });
         dbSetEntity.AddRange(list);
         Save(Context);
     }
 }