搜索(包含查询)在Linq中不起作用 [英] Search(contains query) not working in Linq

查看:68
本文介绍了搜索(包含查询)在Linq中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MVC4工作,我们在我们的项目中使用Linq,Jquery和MySQL作为数据库,Mysql在我的PC中包含查询返回0仅在其他PC中Same Contains查询返回正确的结果。这里有什么问题,让我知道问题在于linq或MySQL。我的Linq代码为Mysql Contains查询是



  public  IList< medicalintake> ; GetChiefComplaintAutoCompleteList( string  findText, int  intakeTypeId, int  SpecialtyId)
{
return _context.medicalintakes.Where(r = > r.IntakeName.Contains(findText)&& r.IntakeTypeId == intakeTypeId&& r.MedicalSpecialtyId == SpecialtyId)。ToList();
}

解决方案

我们的信息非常有限,无法诊断此查询为何在您的计算机上返回不同的结果集。根据我的个人经验,我怀疑它是两个问题之一。



第一个问题是计算机上安装的Entity Framework版本。如果您拥有MySQL提供商的旧版本或新版本,那么其他所有人,可能会产生稍微不同的查询。



第二个问题,我个人认为更有可能的是,您没有相同版本的数据库,用于本地开发,或者您没有连接到与团队其他成员相同的数据库服务器。



解决此问题的最佳方法是在您的计算机和另一台计算机上分析查询。这将帮助您确定两台机器之间的差异,并希望是根本原因。下面是一些帮助您开始在MySQL中进行性能分析的链接。



如何使用MySQL查询分析 [ ^ ]

如何配置MySQL [ ^ ]

Hi, i'm working in MVC4 we are using Linq,Jquery and MySQL as database in our project, Mysql contains query return "0" in my PC only in others PC the Same Contains query return correct result. What's the problem here, Let me know the problem is with linq or MySQL. My Linq code for Mysql Contains query is

public IList<medicalintake> GetChiefComplaintAutoCompleteList(string findText, int intakeTypeId, int SpecialtyId)
        {
            return _context.medicalintakes.Where(r => r.IntakeName.Contains(findText) &&               r.IntakeTypeId == intakeTypeId && r.MedicalSpecialtyId==SpecialtyId).ToList();
        }

解决方案

We have very limited information to diagnose why this query returns a different result set on your computer versus others. From my personal experience, I suspect it to be one of two issues.

The first issue is the version of Entity Framework installed on your computer. If you have an older or new version of the MySQL provider then everyone else, it is possible that it is generating a slightly different query.

The second issue, and I personally think more likely, is you don't have the same version of the database, for local development, or you are not connecting to the same database server as the rest of your team.

The best way to troubleshoot this is through profiling the query on your machine and on another machine. This will help you to identify the difference bewteen the two machines and hopefully the root cause. Below are some links to help you get started with profiling in MySQL.

How to use MySQL Query Profiling[^]
How to Profile MySQL[^]


这篇关于搜索(包含查询)在Linq中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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