首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

linq 通过数组查询 (急)

2012-12-23 
linq 通过数组查询在线等 (急) string[] numbers this.HidCIdList.Value.Split()var Query (from p

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))

热点排行