public static IList <VendorProductEntity> QueryByVendor(string vendorId) { var list = new List <VendorProductEntity>(); var sql = string.Format(@"SELECT {0} FROM vendor_products WHERE unit_id in (select id from units where root_id = @p_vendor_id)", COLUMN_SQL); var db = DatabaseFactory.CreateDatabase(); var dc = db.GetSqlStringCommand(sql); db.AddInParameter(dc, "p_vendor_id", DbType.String, vendorId); using (var reader = db.ExecuteReader(dc)) { while (reader.Read()) { var entity = new VendorProductEntity(); entity.Init(reader); list.Add(entity); } } return(list); }
public static VendorProductEntity Get(string unitId, string productId) { var sql = string.Format(@"select {0} from vendor_products where unit_id = @p_unit_id and product_id = @p_product_id", COLUMN_SQL); var db = DatabaseFactory.CreateDatabase(); var dc = db.GetSqlStringCommand(sql); db.AddInParameter(dc, "p_unit_id", DbType.String, unitId); db.AddInParameter(dc, "p_product_id", DbType.String, productId); using (var reader = db.ExecuteReader(dc)) { if (reader.Read()) { var entity = new VendorProductEntity(); entity.Init(reader); return(entity); } } return(null); }