//using System; //using System.Collections.Generic; //using System.Linq; //using System.Linq.Expressions; //namespace Y.DB.DAO //{ // public class Muse : IDbContext // { // DbTable db; // public Muse() // { // db = new DbTable(); // } // public int Add(T EntityObj, bool isSave = true) where T : class // { // try // { // this.db.Set().Add(EntityObj); // if (isSave) // { // return Save(); // } // } // catch (Exception e) { } // return 0; // } // public int Adds(IEnumerable EntityObjs) where T : class // { // try // { // db.Set().AddRange(EntityObjs); // return Save(); // } // catch (Exception e) { return 0; } // } // public int Del(T EntityObj, bool isSave) where T : class // { // try // { // this.db.Set().Remove(EntityObj); // if (isSave) // { // return Save(); // } // } // catch (Exception e) { } // return 0; // } // public int Dels(IEnumerable EntityObjs) where T : class // { // try // { // this.db.Set().RemoveRange(EntityObjs); // return Save(); // } // catch (Exception e) { } // return 0; // } // public int Update(T EntityObj, bool isSave) where T : class // { // try // { // this.db.Entry(EntityObj).State = EntityState.Modified; // if (isSave) // { // return Save(); // } // } // catch (Exception e) { } // return 0; // } // public int Save() // { // return db.SaveChanges(); // } // public T Get(Expression> expression, string[] include) where T : class // { // try // { // if (include != null && include.Count() > 0) // { // DbQuery query = GetInclude(include); // if (query != null) // return query.FirstOrDefault(expression); // } // return this.db.Set().FirstOrDefault(expression); // } // catch (Exception e) // { // } // return null; // } // public IEnumerable Gets(Expression> expression, string[] include) where T : class // { // try // { // if (include != null && include.Count() > 0) // { // DbQuery query = GetInclude(include); // if (query != null) // return query.Where(expression).ToList(); // } // } // catch (Exception) // { // throw; // } // return db.Set().Where(expression).ToList(); // } // public IEnumerable GetAll(string[] include, bool track) where T : class // { // if (include != null && include.Count() > 0) // { // DbQuery query = GetInclude(include); // if (query != null) // if (track) // return query.ToList(); // else // return query.AsNoTracking().ToList(); // } // if (!track) // db.Set().AsNoTracking().ToList(); // return db.Set().ToList(); // } // private DbQuery GetInclude(string[] include) where T : class // { // DbQuery searchCondition = null; // foreach (var item in include) // { // if (searchCondition == null) // searchCondition = this.db.Set().Include(item); // else // searchCondition = searchCondition.Include(item); // } // return searchCondition; // } // public bool Any(Expression> expression, string[] include) where T : class // { // try // { // if (include != null && include.Count() > 0) // { // DbQuery query = GetInclude(include); // if (query != null) // return query.Any(expression); // } // return this.db.Set().Any(expression); // } // catch (Exception e) // { // } // return false; // } // public DbSet Do() where T : class // { // return db.Set(); // } // public IEnumerable ExecuteSqlCom(string sql, U paramObjs) // where U : class // where T : class // { // return db.Set().SqlQuery(sql, paramObjs); // } // public void Dispose() // { // db.Dispose(); // } // } //}