关于linq的简单问题 [英] simple question about linq
问题描述
你好!
如果我有这个简单的linq结构
var temp =来自myWorksheetList中的o
其中o.ID == workSheetID
选择o.subFileID;
这将始终只给出一个temp记录,这是
selct o.subfileID
如果我现在想从这个临时集合中获取字符串值,那么
最简单的方法是什么这个。
有点像
string myID = temp.ToString();
// Tony
Tony Johansson写道:
您好!
如果我有这个简单的linq结构
var temp =来自myWorksheetList中的o
其中o.ID == workSheetID
选择o.subFileID;
这将始终只给出一个temp记录,这是结果
来自s elct o.subfileID
如果我现在想从这个临时集合中获取字符串值,那么
最简单的方法是什么。
有点像
string myID = temp.ToString();
// Tony
那可能会给你一个数据类型的字符串...
string myID = temp.First();
或者
string myID = temp [0];
-
G?ran Andersson
_____
http://www.guffa .com
你好!
这不起作用,因为你得到了编译错误。
// Tony
" G?ran Andersson" < gu *** @ guffa.com写信息
新闻:ev ************** @ TK2MSFTNGP02.phx.gbl ...
Tony Johansson写道:
>你好!
如果我有这个简单的linq建设
var temp =来自myWorksheetList中的o
其中o.ID == workSheetID
选择o.subFileID;
这将始终只给出一个结果记录在temp中这是结果来自selct o.subfileID
如果我现在想从这个临时集合中获取字符串值是什么
最简单的
这样做的方法。
像
字符串myID = temp.ToString();
// Tony
这可能会给你一个包含数据类型的字符串...
string myID = temp.First();
或者
string myID = temp [0];
-
G?ran安德森
_____
http://www.guffa.com
< blockquote>如果将o.subFileID定义为字符串,它应该可以正常工作。你确实没有说明它是如何定义的。也许:string myID = temp.First()。ToString();
" Tony Johansson"写道:
你好!
这不起作用,因为你得到编译错误。
>
// Tony
" G ?? ran Andersson" < gu *** @ guffa.com写信息
新闻:ev ************** @ TK2MSFTNGP02.phx.gbl ...
Tony Johansson写道:
你好!
如果我有这个简单的linq构造
var temp =来自myWorksheetList中的o
其中o.ID == workSheetID
select o.subFileID;
这个结果总是只给出一个结果记录,这就是结果
来自selct o.subfileID
如果我现在想要从这个临时集合中获取字符串值,那么
最简单的方法是什么。
有些事情如
string myID = temp.ToString();
// Tony
这可能会给你一个数据类型的字符串...
string myID = temp.First();
或也许
string myID = temp [0];
-
G ??跑安德森
_____
http://www.guffa.com
Hello!
If I have this simple linq construction
var temp = from o in myWorksheetList
where o.ID == workSheetID
select o.subFileID;
This will always give only a singe record in temp which is the result from
selct o.subfileID
If I now want to get the string value from this temp collection what is the
easiest way to do this.
Some thing like
string myID = temp.ToString();
//Tony
Tony Johansson wrote:Hello!
If I have this simple linq construction
var temp = from o in myWorksheetList
where o.ID == workSheetID
select o.subFileID;
This will always give only a singe record in temp which is the result
from selct o.subfileID
If I now want to get the string value from this temp collection what is the
easiest way to do this.
Some thing like
string myID = temp.ToString();
//TonyThat will probably give you a string with the data type...
string myID = temp.First();
or perhaps
string myID = temp[0];
--
G?ran Andersson
_____
http://www.guffa.com
Hello!
This doesn'' work because you get compile error.
//Tony
"G?ran Andersson" <gu***@guffa.comwrote in message
news:ev**************@TK2MSFTNGP02.phx.gbl...Tony Johansson wrote:>Hello!
If I have this simple linq construction
var temp = from o in myWorksheetList
where o.ID == workSheetID
select o.subFileID;
This will always give only a singe record in temp which is the result
from selct o.subfileID
If I now want to get the string value from this temp collection what is
the
easiest way to do this.
Some thing like
string myID = temp.ToString();
//Tony
That will probably give you a string with the data type...
string myID = temp.First();
or perhaps
string myID = temp[0];
--
G?ran Andersson
_____
http://www.guffa.com
It should have worked fine if o.subFileID is defined as a string. You did
not say how it was defined. Perhaps: string myID = temp.First().ToString();
"Tony Johansson" wrote:
Hello!
This doesn'' work because you get compile error.
//Tony
"G??ran Andersson" <gu***@guffa.comwrote in message
news:ev**************@TK2MSFTNGP02.phx.gbl...Tony Johansson wrote:Hello!
If I have this simple linq construction
var temp = from o in myWorksheetList
where o.ID == workSheetID
select o.subFileID;
This will always give only a singe record in temp which is the result
from selct o.subfileID
If I now want to get the string value from this temp collection what is
the
easiest way to do this.
Some thing like
string myID = temp.ToString();
//TonyThat will probably give you a string with the data type...
string myID = temp.First();
or perhaps
string myID = temp[0];
--
G??ran Andersson
_____
http://www.guffa.com
这篇关于关于linq的简单问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!