确定返回类型 [英] Determining the returning type

查看:111
本文介绍了确定返回类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在函数中使用了类似以下代码的查询:

Hi,
I used a query like the following code in a function:

var WellObjCode_WellNo = from c in DC.WellGeneralInfos where c.FieldObjCode == _fieldObjectCode select new { WellObjectcode = c.WellObjCode, WellNO = c.WellName };
            return WellObjCode_WellNo;


我想返回WellObjCode_WellNo
这是一个有2列的表格.为了确定此返回类型,我应该在函数中编写什么内容.我认为应该像


I want to return WellObjCode_WellNo
which is a table with 2 collumns. what should I write in a function in order to determine this returning type. I think that it should be sth like

Iqueryable<"A_Type">

一样,但是我应该用什么代替"A_Type"?
提前非常感谢!

, but what should I put in place of "A_Type" ?
Thanks a lot in advance!

推荐答案


匿名类型与任何其他引用类型没有什么不同,除了它不能强制转换为对象以外的任何类型.匿名类型具有方法范围.有关更多详细信息,请参见 http://msdn.microsoft.com/en-us/library/bb397696.aspx [^ ]
如果需要传递方法的结果,最好使用强类型的对象.然后可以使用IEnumerable<<< UrType>>作为返回类型.
Hi,
An anonymous type is no different from any other reference type, except that it cannot be cast to any type except for object.An anonymous type has method scope. For more details see http://msdn.microsoft.com/en-us/library/bb397696.aspx[^]
It is better to use a strongly typed object if you need to pass the result from the method.Then you can use IEnumerable <<UrType>> as return type.


这篇关于确定返回类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆