Esempio n. 1
0
        public List<Product> getProductListInfoData(string id)
        {
            List<Product> list = null;
            try
            {
                IParameterMapper ipmapper = new getProductListInfoDataParameterMapper();
                DataAccessor<Product> tableAccessor;
                string strSql = @"select case when a.TypeName is null then a.TypeName else a.TypeName end as ProductTypeName1,
            a.TypeName as ProductTypeName2,
            case when a.TypeName is null then a.OrderNo else a.OrderNo end as OrderNo
            ,b.Id,b.ProductName
              ,b.ProductType
              ,b.Code
              ,b.PinYin
              ,b.Unit
              ,b.MinUnit
              ,b.MinCount
              ,b.Price
              ,null as OriginalImage
              ,null as ThumbImage
              ,b.BarCode
              ,b.Status
              ,b.RestaurantId
              ,b.Type
              ,b.MaterialId
              ,b.IsDiscount
               ,a.IsServiceType,pf.OrderCount,pf.FavCount from ProductType a
            inner join Product b on a.RestaurantId=b.RestaurantId and a.TypeId=b.ProductType
            left join ProductFav pf on pf.ProductId=b.Id
            where 1=1 and b.Status=1 and a.IsServiceType=0 and b.RestaurantId=@RestaurantId
            order by OrderNo,a.OrderNo";
                tableAccessor = db.CreateSqlStringAccessor(strSql, ipmapper, MapBuilder<Product>.
                    MapAllProperties()
                    /*.Map(t => t.ProductTypeName1).ToColumn("ProductTypeName1")
                    .Map(t => t.ProductTypeName2).ToColumn("ProductTypeName2")
                    .Map(t => t.OrderNo).ToColumn("OrderNo")
                    .Map(t => t.Id).ToColumn("Id")
                    //.Map(t => t.TypeId).ToColumn("TypeId")
                    .Map(t => t.ProductName).ToColumn("ProductName")
                    .Map(t => t.ProductType).ToColumn("ProductType")
                    .Map(t => t.Code).ToColumn("Code")
                    .Map(t => t.PinYin).ToColumn("PinYin")
                    .Map(t => t.Unit).ToColumn("Unit")
                    .Map(t => t.MinUnit).ToColumn("MinUnit")
                    .Map(t => t.MinCount).ToColumn("MinCount")
                    .Map(t => t.Price).ToColumn("Price")
                    .Map(t => t.OriginalImage).ToColumn("OriginalImage")
                    .Map(t => t.ThumbImage).ToColumn("ThumbImage")
                    .Map(t => t.BarCode).ToColumn("BarCode")
                    .Map(t => t.Status).ToColumn("Status")
                    .Map(t => t.RestaurantId).ToColumn("RestaurantId")
                    .Map(t => t.Type).ToColumn("Type")
                    .Map(t => t.MaterialId).ToColumn("MaterialId")
                    .Map(t => t.IsDiscount).ToColumn("IsDiscount")
                    .Map(t => t.IsServiceType).ToColumn("IsServiceType")
                    */
                    .Build());
                list = tableAccessor.Execute(new string[] { id }).ToList();
                return list;

            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                return null;
            }
        }
Esempio n. 2
0
        public List <Product> getProductListInfoData(string id)
        {
            List <Product> list = null;

            try
            {
                IParameterMapper       ipmapper = new getProductListInfoDataParameterMapper();
                DataAccessor <Product> tableAccessor;
                string strSql = @"select case when a.TypeName is null then a.TypeName else a.TypeName end as ProductTypeName1,
a.TypeName as ProductTypeName2,
case when a.TypeName is null then a.OrderNo else a.OrderNo end as OrderNo
,b.Id,b.ProductName
      ,b.ProductType
      ,b.Code
      ,b.PinYin
      ,b.Unit
      ,b.MinUnit
      ,b.MinCount
      ,b.Price
      ,null as OriginalImage
      ,null as ThumbImage
      ,b.BarCode
      ,b.Status
      ,b.RestaurantId
      ,b.Type
      ,b.MaterialId
      ,b.IsDiscount 
       ,a.IsServiceType,pf.OrderCount,pf.FavCount from ProductType a 
inner join Product b on a.RestaurantId=b.RestaurantId and a.TypeId=b.ProductType
left join ProductFav pf on pf.ProductId=b.Id
where 1=1 and b.Status=1 and a.IsServiceType=0 and b.RestaurantId=@RestaurantId
order by OrderNo,a.OrderNo";
                tableAccessor = db.CreateSqlStringAccessor(strSql, ipmapper, MapBuilder <Product> .
                                                           MapAllProperties()

                                                           /*.Map(t => t.ProductTypeName1).ToColumn("ProductTypeName1")
                                                            * .Map(t => t.ProductTypeName2).ToColumn("ProductTypeName2")
                                                            * .Map(t => t.OrderNo).ToColumn("OrderNo")
                                                            * .Map(t => t.Id).ToColumn("Id")
                                                            * //.Map(t => t.TypeId).ToColumn("TypeId")
                                                            * .Map(t => t.ProductName).ToColumn("ProductName")
                                                            * .Map(t => t.ProductType).ToColumn("ProductType")
                                                            * .Map(t => t.Code).ToColumn("Code")
                                                            * .Map(t => t.PinYin).ToColumn("PinYin")
                                                            * .Map(t => t.Unit).ToColumn("Unit")
                                                            * .Map(t => t.MinUnit).ToColumn("MinUnit")
                                                            * .Map(t => t.MinCount).ToColumn("MinCount")
                                                            * .Map(t => t.Price).ToColumn("Price")
                                                            * .Map(t => t.OriginalImage).ToColumn("OriginalImage")
                                                            * .Map(t => t.ThumbImage).ToColumn("ThumbImage")
                                                            * .Map(t => t.BarCode).ToColumn("BarCode")
                                                            * .Map(t => t.Status).ToColumn("Status")
                                                            * .Map(t => t.RestaurantId).ToColumn("RestaurantId")
                                                            * .Map(t => t.Type).ToColumn("Type")
                                                            * .Map(t => t.MaterialId).ToColumn("MaterialId")
                                                            * .Map(t => t.IsDiscount).ToColumn("IsDiscount")
                                                            * .Map(t => t.IsServiceType).ToColumn("IsServiceType")
                                                            */
                                                           .Build());
                list = tableAccessor.Execute(new string[] { id }).ToList();
                return(list);
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                return(null);
            }
        }