Click here to Skip to main content
15,901,035 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Thought of the Day Pin
jeron12-Apr-18 6:23
jeron12-Apr-18 6:23 
GeneralRe: Thought of the Day Pin
RickZeeland2-Apr-18 6:29
mveRickZeeland2-Apr-18 6:29 
GeneralRe: Thought of the Day Pin
PIEBALDconsult2-Apr-18 6:24
mvePIEBALDconsult2-Apr-18 6:24 
GeneralRe: Thought of the Day Pin
Dr.Walt Fair, PE2-Apr-18 13:03
professionalDr.Walt Fair, PE2-Apr-18 13:03 
GeneralRe: Thought of the Day Pin
DRHuff2-Apr-18 13:38
DRHuff2-Apr-18 13:38 
GeneralRe: Thought of the Day Pin
Dr.Walt Fair, PE3-Apr-18 15:54
professionalDr.Walt Fair, PE3-Apr-18 15:54 
GeneralRe: Thought of the Day Pin
DRHuff3-Apr-18 16:16
DRHuff3-Apr-18 16:16 
GeneralThat's what you get for being an early adopter... Pin
Sander Rossel2-Apr-18 5:06
professionalSander Rossel2-Apr-18 5:06 
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:
C#
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:
SQL
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 Cry | :((
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 WTF | :WTF: OMG | :OMG:

Of course we're only dealing with sets here, so there's no real need to support any set operators Sigh | :sigh:
I know .NET Core and EF Core aren't exactly proven technologies yet, but come on... WTF | :WTF:

GeneralRe: That's what you get for being an early adopter... Pin
Nish Nishant2-Apr-18 5:27
sitebuilderNish Nishant2-Apr-18 5:27 
GeneralRe: That's what you get for being an early adopter... Pin
Sander Rossel2-Apr-18 5:42
professionalSander Rossel2-Apr-18 5:42 
GeneralRe: That's what you get for being an early adopter... Pin
Nish Nishant2-Apr-18 5:43
sitebuilderNish Nishant2-Apr-18 5:43 
GeneralRe: That's what you get for being an early adopter... Pin
#realJSOP2-Apr-18 6:09
professional#realJSOP2-Apr-18 6:09 
GeneralRe: That's what you get for being an early adopter... Pin
Nish Nishant2-Apr-18 6:22
sitebuilderNish Nishant2-Apr-18 6:22 
GeneralRe: That's what you get for being an early adopter... Pin
#realJSOP2-Apr-18 6:35
professional#realJSOP2-Apr-18 6:35 
GeneralRe: That's what you get for being an early adopter... Pin
Nish Nishant2-Apr-18 6:37
sitebuilderNish Nishant2-Apr-18 6:37 
GeneralRe: That's what you get for being an early adopter... PinPopular
#realJSOP2-Apr-18 6:47
professional#realJSOP2-Apr-18 6:47 
GeneralRe: That's what you get for being an early adopter... Pin
Nish Nishant2-Apr-18 6:47
sitebuilderNish Nishant2-Apr-18 6:47 
GeneralRe: That's what you get for being an early adopter... Pin
abmv2-Apr-18 7:51
professionalabmv2-Apr-18 7:51 
GeneralRe: That's what you get for being an early adopter... Pin
Vaso Elias2-Apr-18 22:56
Vaso Elias2-Apr-18 22:56 
GeneralRe: That's what you get for being an early adopter... Pin
Sander Rossel3-Apr-18 6:11
professionalSander Rossel3-Apr-18 6:11 
GeneralRe: That's what you get for being an early adopter... Pin
Vaso Elias3-Apr-18 8:27
Vaso Elias3-Apr-18 8:27 
GeneralRe: That's what you get for being an early adopter... Pin
Paulo_JCG2-Apr-18 23:37
professionalPaulo_JCG2-Apr-18 23:37 
GeneralRe: That's what you get for being an early adopter... Pin
Sander Rossel3-Apr-18 6:12
professionalSander Rossel3-Apr-18 6:12 
GeneralRe: That's what you get for being an early adopter... Pin
Steve Naidamast3-Apr-18 3:43
professionalSteve Naidamast3-Apr-18 3:43 
GeneralRe: That's what you get for being an early adopter... Pin
Sander Rossel3-Apr-18 6:13
professionalSander Rossel3-Apr-18 6:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Straw Poll

Were you affected by the geomagnetic storms this past weekend?
Communication disruptions, electrified pipes, random unexplained blue-screens in Windows - the list of effects is terrifying.
  Results   499 votes