|
Although there are potential problems, your short note is correct.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
Not to be negative, but after a weekend to recharge, that's what you come up with? We're gonna have to keep an ion you.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
Watt did you expect?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Something more shocking, you know something that makes you go "ohm my!".
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
It's clearly your revenge after being involved into a fight recently, but remember: violence never solved anything
|
|
|
|
|
Non sequitur... a Prius doesn't have enough power.
|
|
|
|
|
Now that the i
Phones have facial recognition, if you put it in your back pocket does Siri say. Hello there,
Butt face??
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
I tried it out - mine said "Hello there Walt Fair Jr".
I'm pretty sure I would not like to live in a world in which I would never be offended.
I am absolutely certain I don't want to live in a world in which you would never be offended.
Freedom doesn't mean the absence of things you don't like.
Dave
|
|
|
|
|
Well, Siri never metr me or my butt face, either!
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Well that is even scarier then - she must have scraped it off the web somewhere!
|
|
|
|
|
So I have this project in .NET Core 2.0 with Entity Framework Core 2.0.
I have this entity which can be linked to other records of that same entity, let's say people.
So we have John, Bob, and Mary.
Mary can be linked to John and Bob.
My goal is simple, get all people that are not yet linked to the current person.
The LINQ query looks something like this:
var result = context.Persons.Select(p => p.Name)
.Except(context.PersonLink.Where(pl => pl.PersonId == x)
.Select(pl => pl.PersonLink.Name))
.OrderBy(n => n)
.Skip(a).Take(b).ToList(); And I'd except the SQL To look something like this:
SELECT Name
FROM Person
EXCEPT
SELECT Name
FROM PersonLink pl
JOIN Person p ON p.Id = pl.PersonLinkId
WHERE pl.PersonId = x
ORDER BY Name
OFFSET a FETCH NEXT b ROWS ONLY Awfully easy.
Except EF Core messes this up.
It first gets the first set, then the second set, does the comparison in memory and, thus, the offset fetch in memory as well.
The result, in this case, is that the entire Person table is send to my client app, 8000 records, instead of the 100 I'm asking for.
It get's worse, let's say 7999 people are linked, I now have to get 15999 records to my client to end up with 1
Checked my code, my DbContext, Entity classes, re-read my LINQ query a thousand times, even tried it in EF6, but everything seemed fine.
Then I stumbled upon Query: Translate IQueryable.Concat/Union/Intersect/Except/etc. to server · Issue #6812 · aspnet/EntityFrameworkCore · GitHub[^]
It seems EF Core simply doesn't translate set operators to SQL
Of course we're only dealing with sets here, so there's no real need to support any set operators
I know .NET Core and EF Core aren't exactly proven technologies yet, but come on...
|
|
|
|
|
Sander Rossel wrote: EF Core simply doesn't translate set operators to SQL
Ok, that is a pretty serious problem. Which also hopefully means it will be fixed pretty quickly.
|
|
|
|
|
Thought so too, but one of the people on that GitHub thread says "Changing this to producing a single SQL query on the server isn't currently a top priority because we believe that for many common scenarios (e.g. for the sample queries you posted) there isn't a significant difference."
It was ultimately planned for the 2.1 release, but I've updated to the latest 2.1 preview and it's not yet fixed, so...
|
|
|
|
|
Ouch, tough luck.
I would say it's a good idea to move that piece of code into a stored proc (until they fix this).
|
|
|
|
|
It's time to write a stored proc.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Ahem.
|
|
|
|
|
I don't undesratnd the "ahem". He's using Entity Farcework, and trying to use Linq to get his collection. If he writes a stored proc, he avoids EF's lack of ability, and gets back exactly the results he's expecting instead of all 8000 records.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
I agree and I suggested that exact same thing to him 26 mins before you did, it's right above your post.
|
|
|
|
|
Ahh, I don't read a lot of your stuff. It's too sensitive and touchy-feely.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Oh well.
|
|
|
|
|
u seemed to be an early adopter
Caveat Emptor.
"Progress doesn't come from early risers – progress is made by lazy men looking for easier ways to do things." Lazarus Long
|
|
|
|
|
Till fixed by EF Team, you can run a plain SQL from Entity Framework Core 2.0 and still map to your List<person> if I am right?
|
|
|
|
|
I'll have to check that out.
Don't know about it, but thanks for the tip
|
|
|
|
|
|
Can't you achieve your goal like this?
var result = context.Persons
.Where(p=> !p.PersonLink.Any(pl=>p.Id == pl.PersonLinkId))
.Select(p => p.Name)
.OrderBy(n => n)
.Skip(a).Take(b).ToList();
from the moment you use a select your're requesting a projection.
Paulo Gomes
Measuring programming progress by lines of code is like measuring aircraft building progress by weight.
—Bill Gates
Everything should be made as simple as possible, but not simpler.
—Albert Einstein
|
|
|
|