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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.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
Entity framework 使用linqToEntity(Esql)进行铸造_Entity Framework_C# 4.0_Entity Sql - Fatal编程技术网

Entity framework 使用linqToEntity(Esql)进行铸造

Entity framework 使用linqToEntity(Esql)进行铸造,entity-framework,c#-4.0,entity-sql,Entity Framework,C# 4.0,Entity Sql,我的代码: public List<Book> GetBook(string NameField, object Value) { var queryESQL = @"select VALUE Book from Book where Cast(Book." + NameField + " as string) like '%M%'"; var query = this.Entities.CreateQuery

我的代码:

public List<Book> GetBook(string NameField, object Value)
    {
        var queryESQL = @"select VALUE Book from Book
                 where Cast(Book." + NameField + " as string) like '%M%'";
        var query = this.Entities.CreateQuery<Book>(
                  queryESQL);
        return query.ToList();
    }

铸造时使用
Edm.String
而不是
String

铸造时使用
Edm.String
而不是
String

CreateQuery
方法使用CLR类型,而不是Edm类型,因此,在查询中使用
System.String
而不是
EDM.String

CreateQuery
方法使用CLR类型而不是EDM类型,因此在查询中使用
System.String
而不是
EDM.String

错误:找不到类型“EDM.String”。确保加载了所需的架构,并且正确导入了名称空间。在类型名称第2行第51列附近。@Jack先生:您确定在
EDM.String
中将
S
大写了吗?@StriplingWarrior:是的。我确定错误:找不到类型“EDM.String”。确保加载了所需的架构,并且正确导入了名称空间。靠近类型名称,第2行,第51列。@Jack先生:你确定你把
EDM.String
中的
S
大写了吗?@StriplingWarrior:是的。我确信这对我有用。谢谢虽然我不明白为什么Edm.String不起作用,但这对我来说很有效。谢谢虽然我不明白为什么Edm.String不能工作
public List<Book> GetBook(string NameField, object Value)
    {
        var queryESQL = @"select VALUE Book from Book
                 where Cast(Book." + NameField + " as EDM.string) like '%M%'";
        var query = this.Entities.CreateQuery<Book>(
                  queryESQL);
        return query.ToList();
    }
Type 'EDM.string' could not be found. Make sure that the required schemas are loaded and that the namespaces are imported correctly. Near type name, line 2, column 51.