bubibubi / JetEntityFrameworkProvider

Microsoft Access (Jet) Entity Framework provider
89 stars 26 forks source link

Bug in JetCommand.cs affects TOP and maybe SKIP #52

Open aim12340 opened 4 years ago

aim12340 commented 4 years ago

Hi,

When using table.skip(skipX).take(takeX) I run into empty datasets when skipX > 999.

I tracked it to JetCommand.cs line 288: string stringTopCount = _WrappedCommand.CommandText.Substring(indexOfTop + 4, indexOfTopEnd - indexOfTop).Trim();

The SubString is off by one. Up to 3 digits it is fine but 4 digits gets truncated to 3, so 1100 becomes 110. My fix is:

string stringTopCount = _WrappedCommand.CommandText.Substring(indexOfTop + 5, indexOfTopEnd - indexOfTop).Trim();

becasue " top " is 5 chars long.

I was surprised to not get the same error with SKIP but I see you handle that SubString differently. On line 300 you have

string stringSkipCount = _WrappedCommand.CommandText.Substring(indexOfSkip + 5).Trim();

which I think should be a 6 for the same reason:

string stringSkipCount = _WrappedCommand.CommandText.Substring(indexOfSkip + 6).Trim();

Just to be consistent. It doesn't show the same problem but maybe some edge case will trip it up.

Hope that helps. In a selfish note, any chance of getting this in an RC2? I can't use the source, have to rely on the Nuget package.