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

linq 通过数组查询 在线等 (急)
 string[] numbers =this.HidCIdList.Value.Split(';');
        var Query = (from p in adviceNoteEarnestMoneyTableEntities.View_AdviceNoteRightTable.Where(p => numbers.Contains(p.ProjectID.ToString()))

                     select new
                           {
                               RightsCmpCode = p.RightsCmpCode,
                               RightsCmpName = p.RightsCmpName,
                               ProjectCode = p.ProjectCode,
                               ProjectID = p.ProjectID,
                               ProjectMainNo = p.ProjectMainNo,
                               ProjectTitle = p.ProjectTitle,
                               RightsType = p.RightsType,
                               RightsTypeName = p.RightsTypeName,
                           }).OrderBy(p => p.ProjectID);

        if (Query.Count() > 0)
        {
            this.RepList.DataSource = Query;
            this.RepList.DataBind();
        }
错误 是entity不支持tostring()方法
------解决方案--------------------
当然你也可以这样:
string[] numbers =this.HidCIdList.Value.Split(';').Select(x=>int.Parse(x));
 var Query = (from p in adviceNoteEarnestMoneyTableEntities.View_AdviceNoteRightTable.Where(p => numbers.Contains(p.ProjectID))