【发布时间】:2012-07-04 19:16:35
【问题描述】:
我做了一个 sql 查询,它返回一个字符串 - 服务名称。这是查询:
IQueryable<string> query = from Comp in ServiceGroupdb.ServiceGroupes
where (Comp.GroupID == groupID)
select Comp.Name;
如何从查询中取出字符串?
【问题讨论】:
-
如果您只期望一个响应,为什么要将响应声明为 IQueryable
?多个字符串是否会被视为错误?如果您期望多个响应,则转换为数组,否则在查询中明确并将其更改为返回单个字符串。 -
我希望得到一个字符串
-
但是当我这样做的时候:string name = from Comp in ServiceGroupdb.ServiceGroupes where (Comp.GroupID == groupID) select Comp.Name;
-
我得到:无法将类型 system.linq.IQueryable
隐式转换为字符串
标签: c# .net linq iqueryable