Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何从字符串myTElementName获取远程通信?_C#_Entity Framework_Generics - Fatal编程技术网

C# 如何从字符串myTElementName获取远程通信?

C# 如何从字符串myTElementName获取远程通信?,c#,entity-framework,generics,C#,Entity Framework,Generics,我想创建entityframework的通用查询生成器。我正在尝试将泛型类型传递给以下方法ObjectContext.ExecuteStoreQuery方法(String,Object[])。即: BindingSource mybindingSource = new BindingSource(); mybindingSource.DataSource = con.ExecuteStoreQuery<**SomeMethod**(MyTypeName)>(

我想创建entityframework的通用查询生成器。我正在尝试将泛型类型传递给以下方法
ObjectContext.ExecuteStoreQuery方法(String,Object[])
。即:

BindingSource mybindingSource = new BindingSource();

mybindingSource.DataSource = 
    con.ExecuteStoreQuery<**SomeMethod**(MyTypeName)>(
        myperfectWorkingSql, 
        myperfectWorkingSqlsParams
    );
BindingSource mybindingSource=newbindingSource();
mybindingSource.DataSource=
con.ExecuteStoreQuery(
myperfectWorkingSql,
myperfectWorkingSqlsParams
);
如何从字符串MyTypeName获取远程通讯?我的SomeMethod()函数应该是什么样的?或者我应该使用哪些方法

或者下面的代码也给出了错误?我错了吗

 function fooo ( Type t) {

 BindingSource mybindingSource = new BindingSource();

mybindingSource.DataSource = 
    con.ExecuteStoreQuery<t>(
        myperfectWorkingSql, 
        myperfectWorkingSqlsParams
    );
 }

ERROR: this gives type t or namespace t can not be found !
函数fooo(类型t){
BindingSource mybindingSource=新BindingSource();
mybindingSource.DataSource=
con.ExecuteStoreQuery(
myperfectWorkingSql,
myperfectWorkingSqlsParams
);
}
错误:找不到类型t或命名空间t!

由于您希望从字符串中获取类型,它将在运行时解析,因此您无法执行此类操作。但是,您可以使用反射来调用此方法并提供类型作为泛型参数

可能存在的副本