-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DBContext.Database.SqlQuery<string>(sql) get a wrong result #32435
Comments
@jack-liew your question doesn't seem related to EF, but more to the SQL you're sending to MariaDB; in other words, if you send that SQL directly to MariaDB (without EF), you should see the same result. |
I got a right result by sql. maybe it's not mariaDB's problem. |
With Can you please double-check that you're sending the same SQL with EF and outside EF? If you can't figure it out, then we'll need a minimal, runnable code sample (console program) that shows the problem in order to investigate. |
I'm sorry, but I can't investigate anything based on these two screenshots. As I wrote above, in order to help I need a minimal, runnable code sample (console program). |
Your query returns two columns. You ask EF for a single Use a var output = context.Database.SqlQuery<Result>(sql).ToList();
record Result(string msystem, string flow); |
(thanks @Arjan321, I missed that the query was returning two things!) |
The return result shold be one record with two column, not two record,but ef.database.sqlquery only viewed one record has one column.That's I'm confused about. |
You're using I'm going to close this as the question has been answered, but if you need further guidance feel free to post back here and we'll help. |
#DBContext.Database.SqlQuery(sql) get a wrong result
1. Description
I have two database tables have not any association:
msystems
flows
Now, I need get a one line result set like:
When I write a sql like:
It worked, and the result be I needed. But when I write it in C#:
I got a wrong reslut:
Where is the column "flow"?
Thanks for great work!
2. Include provider and version information
EF Core version: 6
Database provider: (e.g. MariaDB)
Target framework: (e.g. .NET 7.0)
Operating system: Windows 11
IDE: (e.g. Visual Studio Code 1.84.2)
The text was updated successfully, but these errors were encountered: