请教linq问题

selg1984 2013-06-19 03:53:49
public static IQueryable BindActions(bool IsMemberId, int MemberId, string objectid, string compamyName)
{
var q = from a in QHW.Operator.Utils.ProcessScript.OrderActions.Elements("item")
where a.Element("actionGroupId").Value == "0" ||
QHW.Operator.Utils.ContextUtils.CurrentUser.ManagerGroupIdList.Exists(m =>
a.Element("actionGroupId").Value.Split(",".ToCharArray(),StringSplitOptions.RemoveEmptyEntries)
.Contains(m.ToString()))
select new
{
actionName = a.Element("actionName").Value,
actionFunction = a.Element("actionFunction").Value
.Replace("$ObjectId$", IsMemberId ? MemberId.ToString() : objectid).Replace("$CompanyName$", compamyName),
actionDescription = a.Element("actionDescription").Value,
actionGroupId = a.Element("actionGroupId").Value
};
return (IQueryable)q;
}

无法将类型为“WhereSelectEnumerableIterator`2[System.Xml.Linq.XElement,<>f__AnonymousType0`4[System.String,System.String,System.String,System.String]]”的对象强制转换为类型“System.Linq.IQueryable”。
...全文
101 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
threenewbee 2013-06-19
  • 打赏
  • 举报
回复
你试试看 return q.AsQueryable();
threenewbee 2013-06-19
  • 打赏
  • 举报
回复
Linq To XML只能返回IEnumerable<T>
exception92 2013-06-19
  • 打赏
  • 举报
回复
return (IQueryable)q; 居然这样写。。
  • 打赏
  • 举报
回复
返回List呀,直接return q.ToList();
EnForGrass 2013-06-19
  • 打赏
  • 举报
回复
return (IQueryable)q; 不能这样做,q是匿名类型,你可以声明一个类

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧