public Prod.Item ProdItemGet(int id, bool includeSkus = false) { if (includeSkus) { var sql = @"select * from item where id=@id;select * from sku where itemid=@id;"; var cmd = SqlBuilder.Raw(sql, new { id }).ToCommand(); using (var reader = StoreConn.QueryMultiple(cmd)) { var o = reader.Read <Prod.Item>().FirstOrDefault(); if (o != null) { o.Skus = reader.Read <Prod.Sku>().ToList(); } return(o); } } else { var cmd = SqlBuilder .Select("*").From("item") .Where("id=@id", new { id }) .ToCommand(); return(StoreConn.QueryFirstOrDefault <Prod.Item>(cmd)); } }
public Prod.Mini ProdMiniGet(int id) { var sql = @"select id,spuid,userid,catgid,catgrid,code,name,title,stock,price,appprice,retailprice,barcode,brandid,brandname,keyword,propid,propstr,inputid,inputstr,summary,picture,ItemImgStr,PropImgStr,status from item where id=@id; select id,code,barcode,stock,price,propstr,appprice,propid,propstr,status from sku where itemid=@id;"; var cmd = SqlBuilder.Raw(sql, new { id }).ToCommand(); using (var reader = StoreConn.QueryMultiple(cmd)) { var o = reader.Read <Prod.Mini>().FirstOrDefault(); if (o != null) { o.Skus = reader.Read <Prod.Mini.Sku>().ToList(); } return(o); } }