/// <summary>
        /// 商品问题咨询列表.update by liujc
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResultModel GetConsulList(SearchConsle model, out int count)
        {
            var         pro       = base._database.Db.ProductConsult;
            ResultModel result    = new ResultModel();
            int         PageIndex = model.Page;
            int         PageSize  = model.PageSize;
            dynamic     cl;
            dynamic     pc;
            var         query = pro.Query()
                                .LeftJoin(_database.Db.Product_Lang, out cl).On(_database.Db.Product_Lang.ProductId == pro.ProductId && _database.Db.Product_Lang.LanguageID == model.languageID)
                                .LeftJoin(_database.Db.YH_User, out pc).On(_database.Db.YH_User.UserID == pro.UserID)
                                .Select(pro.ProductConsultId,
                                        pro.ProductId,
                                        pro.UserID,
                                        pro.ConsultContent,
                                        pro.ConsultDT,
                                        pro.ReplyBy,
                                        pro.ReplyDT,
                                        pro.ReplyContent,
                                        pro.IsAnonymous,
                                        pc.Phone,
                                        pc.Account,
                                        pc.NickName,
                                        pro.ConsultType
                                        ).Where(pro.ProductId == model.productId).OrderByConsultDTDescending();

            count = query.ToList <ProductConsultModel>().Count;
            if (PageIndex == 1)
            {
                result.Data = query.Take(PageSize).ToList <ProductConsultModel>();
            }
            else
            {
                result.Data = query.Skip((PageIndex - 1) * PageSize).Take(PageSize).ToList <ProductConsultModel>();
            }
            return(result);
        }
        /// <summary>
        /// 商品问题咨询列表.add by liujc
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResultModel GetConsulList(SearchConsle model)
        {
            StringBuilder builder = new StringBuilder(" where pro.ProductId=" + model.productId.ToString());

            if (model.contype > 1 && model.contype < 7)
            {
                builder.Append(" and pro.ConsultType=" + model.contype.ToString());
            }
            else if (model.contype == 7)
            {
                builder.Append(" and pro.ConsultType=7");
            }
            else
            {
            }

            string sql = @"select ProductConsultId,ProductId,UserID,ConsultContent,ConsultDT,ReplyBy,ReplyDT,ReplyContent,IsAnonymous,Phone,Account,NickName,ConsultType,
                        (select count(*) from  UserConsult where ConsultId=x.ProductConsultId and IsGood=1) as IsGood,
                        (select count(*) from  UserConsult where ConsultId=x.ProductConsultId and IsGood=-1) as NotGood
                    from (select ROW_NUMBER()over(order by pro.ConsultDT desc) as row,pro.ProductConsultId,pro.ProductId,pro.UserID,pro.ConsultContent,pro.ConsultDT,pro.ReplyBy,pro.ReplyDT,pro.ReplyContent,pro.IsAnonymous,pc.Phone,pc.Account,pc.NickName,pro.ConsultType 
                    from ProductConsult pro left join Product_Lang c1 on pro.ProductId=c1.ProductId and c1.LanguageID=" + model.languageID +
                         " left join YH_User pc on pc.UserID=pro.UserID" + builder.ToString() + ") as x" +
                         " where row between " + ((model.Page - 1) * model.PageSize + 1).ToString() + " and " + (model.Page * model.PageSize).ToString() +
                         " order by ConsultDT desc";

            ResultModel                result = new ResultModel();
            List <dynamic>             res    = this._database.RunSqlQuery(x => x.ToResultSets(sql))[0];
            List <ProductConsultModel> list   = res.ToEntity <ProductConsultModel>();

            result.Data = list;
            return(result);


            //var pro = base._database.Db.ProductConsult;
            //ResultModel result = new ResultModel();
            //int PageIndex = model.Page;
            //int PageSize = model.PageSize;
            //dynamic cl;
            //dynamic pc;

            //var where = new SimpleExpression(1, 1, SimpleExpressionType.Equal);
            //where = new SimpleExpression(where, pro.ProductId == model.productId, SimpleExpressionType.And);
            //if(model.contype>1 && model.contype<7)
            //{
            //    where = new SimpleExpression(where, pro.ConsultType == model.contype, SimpleExpressionType.And);
            //}
            //else if (model.contype == 7)
            //{
            //    where = new SimpleExpression(where, pro.ConsultType <= 1, SimpleExpressionType.And);
            //    where = new SimpleExpression(where, pro.ConsultType >= 7, SimpleExpressionType.And);
            //}
            //else { }
            //var query = pro.Query()
            //     .LeftJoin(_database.Db.Product_Lang, out cl).On(_database.Db.Product_Lang.ProductId == pro.ProductId && _database.Db.Product_Lang.LanguageID == model.languageID)
            //    .LeftJoin(_database.Db.YH_User, out pc).On(_database.Db.YH_User.UserID == pro.UserID)
            //   .Select(pro.ProductConsultId,
            //       pro.ProductId,
            //       pro.UserID,
            //       pro.ConsultContent,
            //       pro.ConsultDT,
            //       pro.ReplyBy,
            //       pro.ReplyDT,
            //       pro.ReplyContent,
            //       pro.IsAnonymous,
            //       pc.Phone,
            //       pc.Account,
            //       pc.NickName,
            //       pro.ConsultType
            //   ).Where(where).OrderByConsultDTDescending();

            //if (PageIndex == 1)
            //{
            //    result.Data = query.Take(PageSize).ToList<ProductConsultModel>();
            //}
            //else
            //{
            //    result.Data = query.Skip((PageIndex - 1) * PageSize).Take(PageSize).ToList<ProductConsultModel>();
            //}
            //return result;
        }