public static CategoryBrandRankModel FetchCategoryBrand(long pkid, BaseDbHelper db) { string sql = @"SELECT * FROM Activity..tbl_CategoryBrandRank WITH(NOLOCK) WHERE PKID=@PKID"; using (var cmd = new SqlCommand(sql)) { cmd.Parameters.AddWithValue("@PKID", pkid); return(db.ExecuteDataTable(cmd).ConvertTo <CategoryBrandRankModel>().FirstOrDefault()); } }
public static IEnumerable <CategoryBrandRankModel> SelectCategoryBrand(long pkid, DateTime?date, BaseDbHelper db) { string sql = @"SELECT * FROM Activity..tbl_CategoryBrandRank WITH(NOLOCK) WHERE ParentPkid=@PKID"; if (date != null) { sql += " AND Date=@Date"; } using (var cmd = new SqlCommand(sql)) { cmd.Parameters.AddWithValue("@PKID", pkid); if (date != null) { cmd.Parameters.AddWithValue("@Date", date.Value.ToString("yyyy-MM-dd")); } return(db.ExecuteDataTable(cmd).ConvertTo <CategoryBrandRankModel>()); } }