Esempio n. 1
0
 public T Single(Expression <Func <T, bool> > predicate)
 {
     using (innovaEntities context = new innovaEntities())
     {
         return(context.Set <T>().FirstOrDefault(predicate));
     }
 }
Esempio n. 2
0
 public List <T> Filter(Expression <Func <T, bool> > predicate)
 {
     using (innovaEntities context = new innovaEntities())
     {
         return((List <T>)context.Set <T>().Where(predicate).ToList());
     }
 }
Esempio n. 3
0
 public List <T> GetAll()
 {
     using (innovaEntities context = new innovaEntities())
     {
         return((List <T>)context.Set <T>().ToList());
     }
 }
Esempio n. 4
0
 public void Delete(T entity)
 {
     using (innovaEntities context = new innovaEntities())
     {
         context.Entry(entity).State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Esempio n. 5
0
 public void Create(T entity)
 {
     using (innovaEntities context = new innovaEntities())
     {
         context.Set <T>().Add(entity);
         context.SaveChanges();
     }
 }
Esempio n. 6
0
 public void Delete(Expression <Func <T, bool> > predicate)
 {
     using (innovaEntities context = new innovaEntities())
     {
         var entities = context.Set <T>().Where(predicate).ToList();
         entities.ForEach(x => context.Entry(x).State = EntityState.Deleted);
         context.SaveChanges();
     }
 }
Esempio n. 7
0
        public List <GrillaSolAdquisicion> lGrillaSolAdquisicion()
        {
            List <GrillaSolAdquisicion> lGrilla = new List <GrillaSolAdquisicion>();

            using (innovaEntities context = new innovaEntities())
            {
                var query = (from oSol in context.GD_SolAdquisicion
                             join oEmp in context.GD_Empleado on oSol.CodSolicitante equals oEmp.CodEmpleado
                             join oArea in context.GD_Area on oEmp.CodArea equals oArea.CodArea
                             join oEstado in context.GD_Estado on oSol.CodEstado equals oEstado.CodEstado
                             select new
                {
                    Codigo = oSol.CodSolAdquisicion,
                    CodSolicitante = oSol.CodSolicitante,
                    Solicitante = oEmp.ApePaterno + " " + oEmp.ApeMaterno + " " + oEmp.Nombres,
                    CodArea = oEmp.CodArea,
                    Area = oArea.DescArea,
                    FechaEmision = oSol.FechaEmision,
                    CodEstado = oSol.CodEstado,
                    Estado = oEstado.DescEstado
                }).ToList();

                foreach (var oCampos in query)
                {
                    GrillaSolAdquisicion oGrilla = new GrillaSolAdquisicion();
                    oGrilla.Codigo         = oCampos.Codigo;
                    oGrilla.CodSolicitante = oCampos.CodSolicitante;
                    oGrilla.Solicitante    = oCampos.Solicitante;
                    oGrilla.CodArea        = oCampos.CodArea;
                    oGrilla.Area           = oCampos.Area;
                    oGrilla.FechaEmision   = oCampos.FechaEmision;
                    oGrilla.CodEstado      = oCampos.CodEstado;
                    oGrilla.Estado         = oCampos.Estado;

                    lGrilla.Add(oGrilla);
                }
            }

            return(lGrilla);
        }
Esempio n. 8
0
        public List <T> Filter(Expression <Func <T, bool> > predicate, List <Expression <Func <T, object> > > includes)
        {
            List <string> includelist = new List <string>();

            foreach (var item in includes)
            {
                MemberExpression body = item.Body as MemberExpression;
                if (body == null)
                {
                    throw new ArgumentException("The body must be a member expression");
                }

                includelist.Add(body.Member.Name);
            }

            using (innovaEntities context = new innovaEntities())
            {
                DbQuery <T> query = context.Set <T>();

                includelist.ForEach(x => query = query.Include(x));

                return((List <T>)query.Where(predicate).ToList());
            }
        }