示例#1
0
        public static List <T> get <T>(Expression <Func <T, bool> > where  = null,
                                       Expression <Func <T, int> > orderBy = null
                                       , bool firstOrLirst = true, int?top = null) where T : class
        {
            using (var context = new dbEntities())
            {
                IQueryable <T> result = context.Set <T>();
                if (where != null)
                {
                    result = result.Where(where);
                }

                if (orderBy != null)
                {
                    if (firstOrLirst)
                    {
                        result = result.OrderBy(orderBy);
                    }
                    else
                    {
                        result = result.OrderByDescending(orderBy);
                    }
                }

                if (top != null)
                {
                    result = result.Take((int)top);
                }

                return(result.ToList());
            }
        }
示例#2
0
 public static int getMaxID()
 {
     using (var context = new dbEntities())
     {
         return(context.CUSTOMERS.Any() ? context.CUSTOMERS.Max(a => a.SHMO) : 0);
     }
 }
示例#3
0
 public static int getMaxID(Expression <Func <CUSTOMERS, int> > max)
 {
     using (var context = new dbEntities())
     {
         return(context.CUSTOMERS.Any() ? context.CUSTOMERS.Max(max) : 0);
     }
 }
示例#4
0
 public static List <cust_act> returnAllCustact()
 {
     using (var context = new dbEntities())
     {
         return(context.cust_act.Include(c => c.CUSTOMERS).ToList());
     }
 }
示例#5
0
 public static void insert <T>(T Tentity) where T : class
 {
     using (var context = new dbEntities())
     {
         context.Set <T>().Add(Tentity);
         context.SaveChanges();
     }
 }
示例#6
0
 public static void insertEntitySP(string code, string special, string mONAME,
                                   int?group_rdf, int?vis_rdf, string addre, string tell1, decimal?cred,
                                   int?check_eteb, int?just_naghdi, int?MaxManFactor, string sharh)
 {
     using (var context = new dbEntities())
     {
         context.USP_alireza_insert_Customer_test(code, special, mONAME,
                                                  group_rdf, vis_rdf, addre, tell1, cred,
                                                  check_eteb, just_naghdi, MaxManFactor, sharh);
     }
 }
示例#7
0
        public static List <visitors> functionVis(int?visId)
        {
            List <visitors> vis = new List <visitors>();

            using (var context = new dbEntities())
            {
                visitors result = context.visitors.Where(v => v.vis_rdf == visId).FirstOrDefault();
                vis.Add(result);
                if (result.supervisor_rdf != 0)
                {
                    vis.AddRange(functionVis(result.supervisor_rdf));
                }
            }
            return(vis);
        }
示例#8
0
 public UnitOfWork()
 {
     db = new dbEntities();
 }
示例#9
0
 public GenericRepository(dbEntities db)
 {
     _db    = db;
     _dbSet = _db.Set <T>();
 }