我有我在寻找某种药物名称的药物表,但我需要搜索多个名称。而这正是我目前它
的String [] =名新的字符串[2]; 名称[0] =阿哌沙班; 名称[1] =西卢; VAR吃药=(从药物m其中names.Any(m.BrandName.Contains)|| names.Any(m.GenericName.Contains)选择米);
我有什么不工作,我现在卡住了。我知道我很近,但我不能完全弄清楚什么是错的。
修改
有关澄清,如果我在寻找名字西卢,那么名优产品或通用名称会比较长,所以我必须有包含在数据库中的字段。
编辑2 这是我收到的错误。
用于查询经营者的任何不支持的超载。下面是我终于结束了。
VAR吃药=(从db.AdmissionMedications m,其中(names.Any(N => m.BrandName.Contains(N))|| names.Any( N => m.GenericName.Contains(N)))选择米);解决方案
也许财产以后像
VAR吃药=(从药物 m其中names.Any(名称=> name.Equals(m.BrandName)|| m.GenericName 。载有(名))选择M);
I have a medication table that I'm looking for certain drug names, but I need to search for multiple names. Here is where I currently am with it.
string[] names = new string[2]; names[0] = "apixaban"; names[1] = "desirudin"; var meds = (from m in Medications where names.Any(m.BrandName.Contains) || names.Any(m.GenericName.Contains) select m);What I have isn't working, and I'm currently stuck. I know I'm close, but I can't quite figure out what's wrong.
EDIT
For clarification, if the name I'm searching for is desirudin, then the BrandName or Generic name will be longer, so I have to have the contains on the field in the database.
EDIT 2 Here is the error I recieve.
Unsupported overload used for query operator 'Any'.Here is what I finally ended up with
var meds = (from m in db.AdmissionMedications where (names.Any(n => m.BrandName.Contains(n)) || names.Any(n => m.GenericName.Contains(n)) ) select m);解决方案
Maybe somthing like
var meds = (from m in Medications where names.Any(name => name.Equals(m.BrandName) || m.GenericName.Contains(name)) select m);
更多推荐
使用LINQ做一个具有多个值包含
发布评论