❔ Entity framework custom select query
I want to get result for the following query in EF
I fought myself that it should be easy -after all querying some random stuff feels like a basic functionality:
so i tried:
Where
ForeignConstrains
is:
Nope - it cannot directly serialize ForeignConstrains, any other method returns int
so useless for me. Every "solution" just makes DbSet for object or custom type which i do not wish to do, i want to have it purely as an extension method - how hard could it be ?! The closest i got to solution is to get SqlQueryRaw<string>
which returns me TableName
but not ConstrainName
, upon trying string[]
i get same issue:
2 Replies
Just checking here: the same query runs on the same db/connectionstring directly just fine?
The error suggests it's a LINQ-TO-SQL problem...
I'd suggest using Dapper-ORM in that case, through extension methods on your dbcontext like you said... Its basically like doing the raw query but has some nice features for mapping to types in a more "raw" manner (different than linq to Sql)
Or use the barebones c# Sql command and Sql result classes, with those I'm quite sure you can just get back the exact same records as you'd expect
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.