public DataTable FindTable(string strSql, DbParameter[] dbParameter) { using (var dbConnection = dbcontext.Database.Connection) { var IDataReader = new DbHelper(dbConnection).ExecuteReader(CommandType.Text, strSql, dbParameter); return(ConvertExtension.IDataReaderToDataTable(IDataReader)); } }
public IEnumerable <T> FindList <T>(string strSql, DbParameter[] dbParameter) where T : class { using (var dbConnection = dbcontext.Database.Connection) { var IDataReader = new DbHelper(dbConnection).ExecuteReader(CommandType.Text, strSql, dbParameter); return(ConvertExtension.IDataReaderToList <T>(IDataReader)); } }
public IEnumerable <T> FindList <T>(string strSql, DbParameter[] dbParameter, string orderField, bool isAsc, int pageSize, int pageIndex, out int total) where T : class { using (var dbConnection = dbcontext.Database.Connection) { StringBuilder sb = new StringBuilder(); sb.Append(new DatabasePage().SqlPageSql(strSql, dbParameter, orderField, isAsc, pageSize, pageIndex)); total = Convert.ToInt32(new DbHelper(dbConnection).ExecuteScalar(CommandType.Text, "Select Count(1) From (" + strSql + ") t", dbParameter)); var IDataReader = new DbHelper(dbConnection).ExecuteReader(CommandType.Text, sb.ToString(), dbParameter); return(ConvertExtension.IDataReaderToList <T>(IDataReader)); } }
public int Update <T>(T entity) where T : class { dbcontext.Set <T>().Attach(entity); Hashtable props = ConvertExtension.GetPropertyInfo <T>(entity); foreach (string item in props.Keys) { object value = dbcontext.Entry(entity).Property(item).CurrentValue; if (value != null) { if (value.ToString() == " ") { dbcontext.Entry(entity).Property(item).CurrentValue = null; } } else { dbcontext.Entry(entity).Property(item).CurrentValue = null; } dbcontext.Entry(entity).Property(item).IsModified = true; } return(dbTransaction == null?this.Commit() : 0); }