neisbut / EntityFramework.MemoryJoin

Extension for EntityFramework for joins to in-memory data
MIT License
56 stars 24 forks source link

ArgumentOutOfRangeException if query is run which doesn't include a memory list. #2

Closed cjmairair closed 6 years ago

cjmairair commented 6 years ago

If you run FromLocalList, and then you run a query without that local list, you will get an ArgumentOutOfRangeException

The problem is that you don't check whether the query even has that memory list. You just assume it does.

Before you run ModifyQuery below, you should just check that the query has a memory list in it.

    private void ModifyQuery(DbCommand command, InterceptionOptions opts)
    {
        int index = command.CommandText.IndexOf(opts.QueryTableName);
        int num2 = command.CommandText.IndexOf(' ', index); // problems start here
        int num3 = command.CommandText.LastIndexOf(' ', index);

I'm sure you would do more if you had time.The 2000 parameter limit would be good to get rid of. And also, to be able to make multiple local lists and use them in any order - or not use them at all.

neisbut commented 6 years ago

Hi @cjmairair, good point on ArgumentOutOfRangeException. I think I can add check for such case. Will do soon. Actually 2000 parameter limit is in MS SQL only and it is actually workarounded already (you may check TryProcessParameterAsString method), so you can have more than 2000.

And also, to be able to make multiple local lists and use them in any order - or not use them at all.

Sorry, I have different opinion on this. First of all this limit (1 local list) exists in EF6 implementation only, whereas in EF Core you can as many as you want. But, I use this library in my current project with EF6 and it gives me a great performance kick. So choosing between 1 local list limit and the great perfomance kick - I prefer option 2. But of course it is simply my personal preference, I'm going to continue using it.

neisbut commented 6 years ago

Original issue is fixed. Closed due to inactivity.