Click here to Skip to main content
15,798,592 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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();
Updated 7-Jul-15 1:13am

1 solution

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[^]
Share this answer
sankarisiva 7-Jul-15 8:30am    
Sorry, I forget to tell one thing when run the contains query directly in mysql it returns correct result. The Problem here is when i trying to run contains query with Linq only.
virusstorm 7-Jul-15 8:35am    
Refer to my first issue then. Either way, profiling will help you find the root cause.
sankarisiva 8-Jul-15 2:36am    
Yes, you are correct my team running mysql version no. 6.1 but i have mysql version no. 6.2.4 and all in our team including me having entity framework 5.0. I think this is issue. Am i right?
sankarisiva 8-Jul-15 2:52am    
Now i'm updated my Entity Framework to 6.1. After that when i build my solution it produces the following error The type or namespace name 'EntityState' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)
virusstorm 9-Jul-15 12:10pm    
Make sure you have added reference to the System.Data.Entity.dll

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900