日期:2014-05-20  浏览次数:20678 次

为什么查询出来的数据比数据库还多
    aList = aObj.GetListInfo(condition, "");
            uList = uObj.GetListInfo("", "");
            mList = mObj.GetListInfo("", "");
            var result = from p in aList
                     
                         join q in uList on p.i_client_id equals q.UserId
                         join m in mList on q.UserId equals m.BeatedUserID                       
                         select new
                         {
                             p.i_datetime,
                             p.i_client_id,
                             money = p.i_op_id == "客户入金" ? p.e_post_bala.ToString() : "",
                             money2 = p.i_op_id == "客户入金" ? p.e_post_bala.ToString() : "",
                             money3 = p.i_op_id == "申请出金" ? p.e_post_bala.ToString() : "",
                             money4 = p.i_op_id == "客户出金" ? p.e_post_bala.ToString() : "",
                             p.e_post_bala,
                             p.e_current_bala,
                             p.i_flag,
                             m.Bail,
                             q.Fee
                         };

            anp.RecordCount = result.Count();
            this.GridView1.DataSource = result.Skip((anp.CurrentPageIndex - 1) * anp.PageSize).Take(anp.PageSize);

            this.GridView1.DataBind();
好奇怪 ,数据库里面没有那张表的数据库超过1W条,为什么上面这样查出来有70多W条数据,,当然有很多是重复的,,。。 aList 的count值为1000多,uList 是400多,mList 是200多,。。  求解 ,, 在线等,, 急急
------解决方案--------------------
从代码来看是inner join

从你描述的结果来看,又是cross join

不如直接单步调试,查看LINQ语句生成的SQL查询语句是什么