-
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
Custom model in FromSql method #16553
Comments
I've tried this solution before, but my Campaign model doesn't have ImpressionCount and InteractionCount fields. In fact, these fields do not exist in the database. For this reason, I get the error that the ImpressionCount and InteractionCount fields do not exist in contex. These fields are completely virtual. What I need is to give the result of the query directly to me without equalizing any model. |
@scaki Please post a small, runnable project/solution or complete code listing that demonstrates the behavior you are seeing so we can investigate. |
Repository
Campaign Model
CampaignWithImpressionAndInteraction
Error
|
+1 Having the same issue |
That's just invalid C# query. |
@smitpatel yes, i ask how can i do valid query. How can i fix this problem |
@scaki The call to this.MssqlContext.Set<CampaignWithImpressionAndInteraction>().FromSql... |
I've tried this code before, it doesn't work. I solved the problem by adding the CampaignWithImpressionAndInteraction model to MssqlContext. |
Describe what is not working as expected.
I want execute sql query with EFCore. In the old version, there was a sqlquery method, which can be used to define the query result to a special model. I have the FromSql method in my version and I can't use this feature. The query that I want the sum of rows comes up in its own model and I can't reach the count column. How do I resolve this issue?
Steps to reproduce
Further technical details
EF Core version: 2.2.0
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Windows 10
IDE: VSCode
The text was updated successfully, but these errors were encountered: