示例#1
0
 public T Find(Expression <Func <T, bool> > predicate)
 {
     using (RadioContext context = new RadioContext())
     {
         return(context.GetTable <T>().FirstOrDefault(predicate));
     }
 }
示例#2
0
 public List <T> FindAll(Expression <Func <T, bool> > predicate)
 {
     using (RadioContext context = new RadioContext())
     {
         return(context.GetTable <T>().Where(predicate).ToList());
     }
 }
示例#3
0
 public void Add(T entity)
 {
     using (RadioContext context = new RadioContext())
     {
         context.GetTable <T>().InsertOnSubmit(entity);
         context.SubmitChanges();
     }
 }
示例#4
0
        public void DeleteAll(Expression <Func <T, bool> > predicate)
        {
            using (RadioContext context = new RadioContext())
            {
                var entitys = context.GetTable <T>().Where(predicate).ToList();

                if (entitys != null && entitys.Count > 0)
                {
                    context.GetTable <T>().DeleteAllOnSubmit(entitys);
                    context.SubmitChanges();
                }
            }
        }