Ejemplo n.º 1
0
 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));
     }
 }
Ejemplo n.º 2
0
 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));
     }
 }
Ejemplo n.º 3
0
 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));
     }
 }
Ejemplo n.º 4
0
        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() == "&nbsp;")
                    {
                        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);
        }