Esempio n. 1
0
        public List<OrderDetails> getOrderDetaiById(string orderId)
        {
            List<OrderDetails> list = null;
            try
            {
                IParameterMapper ipmapper = new getOrderDetaiByIdParameterMapper();
                DataAccessor<OrderDetails> tableAccessor;
                string strSql = @"
            select od.CreateDate,
                                    od.DetailsId,
                                    od.Discount ,
                                    od.DiscountPrice,
                                    od.OrderId,
                                    od.ProductCount,
                                    od.Remark,
                                    od.SendState,
                                    od.TotalPrice,
                                    od.UnitPrice,
                                    od.UseState ,
                                    od.ProductId ,
                                     p.ProductName
                                    from OrderDetails od  left join   Product p
                on od.ProductId=p.Id and od.OrderId=@OrderId";
                tableAccessor = db.CreateSqlStringAccessor(strSql, ipmapper, MapBuilder<OrderDetails>.MapAllProperties()

                    .Map(t => t.CreateDate).ToColumn("CreateDate")
                    .Map(t => t.DetailsId).ToColumn("DetailsId")
                    .Map(t => t.Discount).ToColumn("Discount")
                    .Map(t => t.DiscountPrice).ToColumn("DiscountPrice")
                    .Map(t => t.OrderId).ToColumn("OrderId")
                    .Map(t => t.ProductCount).ToColumn("ProductCount")
                    .Map(t => t.Remark).ToColumn("Remark")
                    .Map(t => t.SendState).ToColumn("SendState")
                    .Map(t => t.TotalPrice).ToColumn("TotalPrice")
                    .Map(t => t.UnitPrice).ToColumn("UnitPrice")
                    .Map(t => t.UseState).ToColumn("UseState")
                    .Map(t => t.ProductId).ToColumn("ProductId")
                    .Map(t => t.ProductName).ToColumn("ProductName")
                   .Build());
                list = tableAccessor.Execute(new string[] { orderId }).ToList();
                return list;

            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                return null;
            }
        }
        public List <OrderDetails> getOrderDetaiById(string orderId)
        {
            List <OrderDetails> list = null;

            try
            {
                IParameterMapper            ipmapper = new getOrderDetaiByIdParameterMapper();
                DataAccessor <OrderDetails> tableAccessor;
                string strSql = @"
select od.CreateDate,
                                    od.DetailsId,
                                    od.Discount ,
                                    od.DiscountPrice,
                                    od.OrderId,
                                    od.ProductCount,
                                    od.Remark,
                                    od.SendState,
                                    od.TotalPrice,
                                    od.UnitPrice,
                                    od.UseState ,
                                    od.ProductId ,
                                     p.ProductName
                                    from OrderDetails od  left join   Product p  
                on od.ProductId=p.Id and od.OrderId=@OrderId";
                tableAccessor = db.CreateSqlStringAccessor(strSql, ipmapper, MapBuilder <OrderDetails> .MapAllProperties()

                                                           .Map(t => t.CreateDate).ToColumn("CreateDate")
                                                           .Map(t => t.DetailsId).ToColumn("DetailsId")
                                                           .Map(t => t.Discount).ToColumn("Discount")
                                                           .Map(t => t.DiscountPrice).ToColumn("DiscountPrice")
                                                           .Map(t => t.OrderId).ToColumn("OrderId")
                                                           .Map(t => t.ProductCount).ToColumn("ProductCount")
                                                           .Map(t => t.Remark).ToColumn("Remark")
                                                           .Map(t => t.SendState).ToColumn("SendState")
                                                           .Map(t => t.TotalPrice).ToColumn("TotalPrice")
                                                           .Map(t => t.UnitPrice).ToColumn("UnitPrice")
                                                           .Map(t => t.UseState).ToColumn("UseState")
                                                           .Map(t => t.ProductId).ToColumn("ProductId")
                                                           .Map(t => t.ProductName).ToColumn("ProductName")
                                                           .Build());
                list = tableAccessor.Execute(new string[] { orderId }).ToList();
                return(list);
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                return(null);
            }
        }