linqtoentitiescannotconvertinttostring过滤后的文本,并且不等于1,所以我所做的是将ID转换为字符串,如下所示.Contains(文本)).ToList());但它总是返回linqentitynotrecognizedmethod'system.stringtostring()'所以我尝试将dbset转换为listbeforewherestatement正如我在另一篇文章中发现的那样,LINQtoEntitiescannotRecognizingthemethod'System.StringToString()'MVC4中的方法,但我收到另一个错误,指出该列表不包含Where的定义(dbSet是IDbSet的一个实例)publicvirtualIListGetMany(Expressionwhere){returndbset.ToList().Where(哪里).ToList();这是我原来的(当前的)get方法singSystem;使用System.Collections.Generic;使用System.Linq;使用系统文本;使用System.Data.Entity使用System.Data;使用System.Linq.Expressions;使用Spine.ERP.DataAccess.DbFirstDataAccess;使用Spine.ERP.DataModel.Helpers;命名空间Spine.ERP.DataAccess.Infrastructure{publicabstractclassRepositoryBasewhereT:class{privateSSSDBEntitiesdataContext;私有只读IDbSet数据库集;protectedRepositoryBase(IDatabaseFactorydatabaseFactory){DatabaseFactory=databaseFactory;dbset=DataContext.Set();}受保护的IDatabaseFactoryDatabaseFactory{get;私有集;??(dataContext=DatabaseFactory.Get());}}publicvirtualIQueryableGetMany(Expressionwhere){returndbset.哪里哪里);我还能做些什么来解决这个问题吗???有一个可用的SqlFunctions类,其中包含许多可与LINQ一起使用的SQL函数试试看(文本)).ToList());不幸的是,只有一个SqlFunctions.StringConvert(double?number)而没有SqlFunctions.StringConvert(int?number)。但我总是将整数转换为双精度并且它按预期工作。编辑:您之前正在调用ToList。因此,SqlFunctions的任何SqlFunction只能在ToList()非法后在LINQtoEntity查询中调用。尽量不要使用GetMany方法:以上是C#学习教程:linqtoentitiescannotconvertinttostring分享的全部内容。如果对大家有用,需要详细了解C#学习教程,希望大家多多关注——purchaseOrderRepository.Set().Where(x=>SqlFunctions.StringConvert((double?)x.PurchaseOrderID).Contains(正文))本文收集自网络,不代表立场。如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处: