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>()))); }
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)); }
public DataTable FindTableTop <T>(int Top) where T : new() { StringBuilder builder = DatabaseCommon.SelectSql <T>(Top); return(DatabaseReader.ReaderToDataTable(DbHelper.ExecuteReader(CommandType.Text, builder.ToString()))); }
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)); }
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()))); }
public object FindMax <T>(string propertyName) where T : new() { StringBuilder builder = DatabaseCommon.SelectMaxSql <T>(propertyName); return(DbHelper.ExecuteScalar(CommandType.Text, builder.ToString())); }
public List <T> FindList <T>() where T : new() { StringBuilder builder = DatabaseCommon.SelectSql <T>(); return(DatabaseReader.ReaderToList <T>(DbHelper.ExecuteReader(CommandType.Text, builder.ToString()))); }
public int FindCount <T>() where T : new() { StringBuilder builder = DatabaseCommon.SelectCountSql <T>(); return(Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, builder.ToString()))); }