Beispiel #1
0
        public T FindEntity <T>(string propertyName, object propertyValue) where T : new()
        {
            string        str     = propertyName;
            StringBuilder builder = DatabaseCommon.SelectSql <T>();

            builder.Append(" AND ").Append(str).Append("=").Append(DbHelper.DbParmChar + str);
            IList <DbParameter> source = new List <DbParameter> {
                DbFactory.CreateDbParameter(DbHelper.DbParmChar + str, propertyValue)
            };

            return(DatabaseReader.ReaderToModel <T>(DbHelper.ExecuteReader(CommandType.Text, builder.ToString(), source.ToArray <DbParameter>())));
        }
Beispiel #2
0
        public int Update <T>(T entity)
        {
            object        obj2    = 0;
            StringBuilder builder = DatabaseCommon.UpdateSql <T>(entity);

            DbParameter[] parameter = DatabaseCommon.GetParameter <T>(entity);
            obj2 = DbHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), parameter);
            if (Convert.ToInt32(obj2) < 1)
            {
                StringBuilder builderTmp = DatabaseCommon.InsertSql <T>(entity);
                obj2 = DbHelper.ExecuteNonQuery(CommandType.Text, builderTmp.ToString(), parameter);
            }
            return(Convert.ToInt32(obj2));
        }
Beispiel #3
0
        public DataTable FindTableTop <T>(int Top) where T : new()
        {
            StringBuilder builder = DatabaseCommon.SelectSql <T>(Top);

            return(DatabaseReader.ReaderToDataTable(DbHelper.ExecuteReader(CommandType.Text, builder.ToString())));
        }
Beispiel #4
0
 public DataTable FindTablePage <T>(string orderField, string orderType, int pageIndex, int pageSize, ref int recordCount) where T : new()
 {
     return(SqlServerHelper.GetPageTable(DatabaseCommon.SelectSql <T>().ToString(), orderField, orderType, pageIndex, pageSize, ref recordCount));
 }
Beispiel #5
0
        public DataTable FindTable <T>(List <string> queryField) where T : new()
        {
            StringBuilder builder = DatabaseCommon.SelectSql <T>(queryField);

            return(DatabaseReader.ReaderToDataTable(DbHelper.ExecuteReader(CommandType.Text, builder.ToString())));
        }
Beispiel #6
0
        public object FindMax <T>(string propertyName) where T : new()
        {
            StringBuilder builder = DatabaseCommon.SelectMaxSql <T>(propertyName);

            return(DbHelper.ExecuteScalar(CommandType.Text, builder.ToString()));
        }
Beispiel #7
0
        public List <T> FindList <T>() where T : new()
        {
            StringBuilder builder = DatabaseCommon.SelectSql <T>();

            return(DatabaseReader.ReaderToList <T>(DbHelper.ExecuteReader(CommandType.Text, builder.ToString())));
        }
Beispiel #8
0
        public int FindCount <T>() where T : new()
        {
            StringBuilder builder = DatabaseCommon.SelectCountSql <T>();

            return(Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, builder.ToString())));
        }