Commit Graph

281 Commits (2e4f22e30d0dbcecc030efb6c14a9b3fc0eb05e3)

Author SHA1 Message Date
Christopher Jolly db7a513b64 Remove the DeepSkip tag on FirstOrDefault. When generating the sql it was preventing the TOP expression from being generated 2 years ago
Christopher Jolly fbf0f794a7 use .GetMAppStoreObjects to try get the correct table (this is especially needed for properties in split tables). Default to the original storeObject if can't find anything 2 years ago
Christopher Jolly 2dbd0fde32 Rewrite some INNER JOIN's. According to the docs Jet doesn't support an INNER JOIN being nested under a LEFT JOIN. We try to figure out which one's they are and rewrite it. As an INNER JOIN is a join where both sides have a value, we can rewrite it as a LEFT JOIN and then filter out the rows where the columns the join is on is not NULL 2 years ago
Christopher Jolly c46f980c09 Start work on some support for sequence value generation. Still under investigation if possible 2 years ago
Christopher Jolly 944843bfad Some datetime parameters don't work unless they have been properly converted 2 years ago
Christopher Jolly 3ef1503bb9 Translate the Atan2 function 2 years ago
Christopher Jolly 5e32650f6d Dispose of any new JetCommands created when splitting commands properly. This were not being disposed of and still holding a link to the database thereby preventing some file access e.g. Deleting a file 3 years ago
Christopher Jolly 3f5c1b6005 Make sure a DateTime in a constant has a DateTime Type Mapping 3 years ago
Christopher Jolly 429c67ca3a Some skip...take optimization and fix using multiple take after a skip 3 years ago
Christopher Jolly 8c9dff5d36 Initial support for Skip....Take. Take...Skip and Skip currently do not work properly 3 years ago
Christopher Jolly fd57f4a3bd Rename some extension methods so that it doesn't interfere with other providers (namely sql server) 3 years ago
Christopher Jolly fd6c2aec01 Revert ca0feb49 . Same name extensions when using sql server and jet 3 years ago
Christopher Jolly 84e40f5085 Fix some string resources 3 years ago
Cédric Luthi cbb3f94440 Remove unnecessary references in `EntityFrameworkCore.Jet.Data`
Now that `EntityFrameworkCore.Jet.Data` targets `net6.0` those references are not required anymore.

Note that the `Microsoft.Win32.Registry` package reference was the root cause of the failure to publish the `EntityFrameworkCore.Jet.Data` 7.0.0 package because of [warning NU5104][1] (treated as error):
> A stable release of a package should not have a prerelease dependency. Either modify the version spec of dependency "Microsoft.Win32.Registry [6.0.0-preview.5.21301.5, )" or update the version field in the nuspec.

[1]: https://bubibubi.visualstudio.com/EntityFrameworkCore.Jet/_build/results?buildId=280&view=logs&j=67ea8d94-b5a7-504b-2d4b-07baddfad3f1&t=1e07b7f6-b7a1-55f6-9cca-c04683790a41&l=37
3 years ago
Christopher Jolly a9c2f36da5 Jet conversion functions like Cdbl/Csng/CLng don't accept or propogate null values. Normally we can just use an IIF to check if the expression is null or not. That does work fine but here we also check if the base expression is nullable. If the base expression will never return null we can simplify and just use the base expression rather than test for null 3 years ago
Christopher Jolly 6963a165e5 The result of the Round function is never null 3 years ago
Christopher Jolly c8e109fb94 Jet can't candle a left join straight after a cross join. We have to push the cross join specifically down into its own subquery and then do a left join on that 3 years ago
Cédric Luthi 83c29e4c43 Introduce a new typed JetConnectionStringBuilder
This makes it easier to use than the extensions (EntityFrameworkCore.Jet.Data.DbConnectionStringBuilderExtensions) with Get/Set methods.

With the new `JetConnectionStringBuilder` class:

```csharp
var csb = new JetConnectionStringBuilder(DataAccessProviderType.OleDb)
{
    Provider = "Microsoft.ACE.OLEDB.12.0",
    DataSource = @"C:\myFolder\myAccessFile.accdb",
    DatabasePassword = "hunter2",
};
var connectionString = csb.ConnectionString;
```

Without the new `JetConnectionStringBuilder` class:

```csharp
var csb = new OleDbConnectionStringBuilder();
csb.SetProvider("Microsoft.ACE.OLEDB.12.0");
csb.SetDataSource(@"C:\myFolder\myAccessFile.accdb");
csb.SetDatabasePassword("hunter2");
var connectionString = csb.ConnectionString;
```
3 years ago
Cédric Luthi c795ce6228 Make EntityFrameworkCore.Jet available on `net6.0`
By using `[SupportedOSPlatform("windows")]` at assembly level instead of targeting `net6.0-windows`.

This will enable taking a dependency on the EntityFrameworkCore.Jet* NuGet packages on Linux and macOS. The consumer of EntityFrameworkCore.Jet can then decide how to handle [CA1416][1] either by adding `[SupportedOSPlatform("windows")]`, by targeting `net6.0-windows` or by testing `OperatingSystem.IsWindows()` at runtime.

[1]: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1416
3 years ago
Christopher Jolly 12aca42198 Add option to use the normal short text type when mapping against an unbounded System.String instead of long text/memo. Jet has limitations when using memo (e.g. joins are not supported) 3 years ago
Christopher Jolly 950089a113 Set the precision to be maximum of 28 (Jet limit).
When using property.HasConversion<decimal>() the default for EF Core is with precision 38 and scale 17 which is passed Jet's limit
3 years ago
Christopher Jolly acc3fd5223 Revert "Set the precision to be maximum of 28 (Jet limit)."
This reverts commit a1904bf113.
3 years ago
Christopher Jolly a1904bf113 Set the precision to be maximum of 28 (Jet limit).
When using property.HasConversion<decimal>() the default for EF Core is with precision 38 and scale 17 which is passed Jet's limit
3 years ago
Christopher Jolly dc049d804d Do the same clr type check when mapping "text" as what we do for other store type mappings. This allows conversions do work better (e.g. originally a mappingInfo with a System.Char type was passed in with store type of "text" and a variable length or unbounded string type was returned but with clr type of System.String. Going with the extra checked returns null and gets EF Core to find a converter and then do the mapping again on the converted type 3 years ago
Christopher Jolly ee54f1fac0 Use MidB/InstrB for the byte versions. (still doesnt produce correct results yet) 3 years ago
Christopher Jolly ee30910fa9 Update the ValueGeneratorSelector to current ef core style. Don't rely on sequential guid's as Jet doesn't order them properly (treats them as string as sorts them numerically/alphabetically) 3 years ago
Christopher Jolly 0eb8baefa9 Add a clause/filter to the index to ignore nulls 3 years ago
Christopher Jolly 306585af13 When dealing with convert, if we don't have a specific conversion function, try just send the original operand and let Jet work with the types. Seems to be fairly lenient 3 years ago
Christopher Jolly 6cb1748237 Remove sbyte from clr mappings. Not needed as EF Core will use automatic conversions for those types. EF Core SQL Server behaves the same 3 years ago
Christopher Jolly 9489bc4564 Jet seems to output bytes only as an array. so a single byte becomes a byte[1] array. Return the first byte of that array in this instance 3 years ago
Christopher Jolly 3b0bc7d5ad Fix the GetValueGenerated function. Was not being called and as such for an identity the ValueGenerated.OnAdd was not being set 3 years ago
Christopher Jolly 78f3dbae15 Use our own Byte type mapping for generating the correct string literal 3 years ago
Christopher Jolly bc5b51fa4a Fix check against typeof JetBoolTypeMapping. For the tests Everything is Bytes/Strings all type mappings are the same which makes the check not behave correctly 3 years ago
Christopher Jolly f15d60aaab Fix escaping wild chars. Use the correct form to escape. Also the LIKE clause does nt have an ESCAPE clause to set the escape char so set that to null 3 years ago
Christopher Jolly 73ef68188f Ordering of boolean: Rather order by the NOT expression rather than change the ascending or descending order. NULL values are handled in the correct order now
Division: If the result of the binary is meant to be integer, use the Jet binary divide operatior '\'
3 years ago
Christopher Jolly 87aa0dbe93 Fix incorrect check for whether ordering expression is boolean typeexpression if it is a boolean type. 3 years ago
Christopher Jolly 03579d380c Add a JetGuidTypeMapping class. We need to override the template for the SQL literal. Jet uses the format with th curly braces at the beginning and end. Default (and same as sql server) is the format without curly braces 3 years ago
Christopher Jolly d7033125be Properly read a TimeSpan value from the database.
Add member translator for timespan so SQL works
3 years ago
Christopher Jolly 096a0955e2 Add JetQueryableMethodTranslatingExpressionVisitorFactory if needed to override anything from it 3 years ago
Christopher Jolly e01686d4b5 MID doesn't allow a null value for the length parameter. Add a IIF wrapper around it if that argument is marked as nullable.
Added here instead of stringmethodtranslator as we need the nullability optimizations on the sqlfunctionexpression. When wrapped in a caseexpression we get some different optimizations. Produces the correct result on the test case but is different to SQL Server. This way we keep it closer to SQL Server
3 years ago
Christopher Jolly 9355ddb293 LEN propagates nullability 3 years ago
Christopher Jolly a11ca0198d Add SqlTranslatingExpressionVisitor:
- Handles array index of byte[] (currently not working)
- Returns a not translated if we have arithmetic between dates/times. See Projection_containing_DateTime_subtraction in NorthwindSelectQueryJetTest
3 years ago
Christopher Jolly 2b0f468421 Fix conversion translator: only need to translate Convert.To... functions. Was trying to convert other tostring methods and was picking the methods that required an argument which was typically the tostring functions with arguments of the format string or the format provider 3 years ago
Christopher Jolly a2db5066e1 The object tostring translator was doing it on the server. It needs to be handled on the client to get the actual name of the enum rather than its int value
Also handles the boolean special cases
3 years ago
Christopher Jolly b107b2235d SqlExpressionSimplifyingExpressionVisitor simplifies nested coalesce calls into the form of COALESCE(arg1,arg2,...argn)
Jet doesn't have any equivalent so unroll into nest iif calls
3 years ago
Christopher Jolly 3e376ff106 Fix byte array stuff 3 years ago
Christopher Jolly ccef0d4f49 Add Math functions to translate Floor and Ceiling 3 years ago
Christopher Jolly 458197e582 Pass the current dataaccessproviderfactory type to CreateDatabase. Preference will take place using this type before going to the default in case it can't find the type via the connection string.
Fixes #135 and #122
3 years ago
Christopher Jolly f753bc68ea Don't call SearchConditionConvertingExpressionVisitor. Some nullability optimizations through ParameterBasedSqlProcessor and SqlNullabilityProcessor need to be called first and they call SearchConditionConvertingExpressionVisitor 3 years ago
Christopher Jolly 9464868c1d Reverse the order of the indices. We need to work backwards on the string to keep the indices correct 3 years ago
Christopher Jolly cef810999d Fix failed merge 3 years ago
Christopher Jolly 0018d44d88 Fix JetStringMethodTranslator
JetStringMethodTranslator: Merge left 2 copies of some functions around
3 years ago
Christopher Jolly 5ea5fdc446
Merge branch 'master' into ef7 3 years ago
Christopher Jolly a9789216d2 Dual table: Auto detect the dual table name on model load. Use that table for any queries.
Also allow a custom override name to be set
3 years ago
Christopher Jolly fbd8398d95 Timespan needs to map to a DbType of DateTime not Time 3 years ago
Christopher Jolly 29cd983826 Timespan needs to map to a DbType of DateTime not Time 3 years ago
Christopher Jolly 44aea7795b Dual table: Auto detect the dual table name on model load. Use that table for any queries.
Also allow a custom override name to be set
3 years ago
Christopher Jolly f5ebc98417 For DateTimeOffset don't convert to Utc before converting to the Offset 3 years ago
Christopher Jolly 0220511c58 Revert mistaken change to _bool type mapping 3 years ago
Christopher Jolly e14b48db47 Update tests 3 years ago
Christopher Jolly 710376d50f Enable nullable on src projects (not tests)
Fix Math and String translator to add missing translations and make it similar to how sql server generates
Update lots of tests
3 years ago
Christopher Jolly 59bc0d813a Change option from 0 to 1 for InStr. Make it use vbTextCompare which is case insensitive 3 years ago
Christopher Jolly 0f2b0c3447 Update to EF 7 GA version 3 years ago
Christopher Jolly b80c0c8128 Update tests 3 years ago
Christopher Jolly dec08fc0ed make modification command bath size to 1 3 years ago
Christopher Jolly 0e7d080ebd Initial ef7 update 3 years ago
Christopher Jolly 75e381b52c Update tests 3 years ago
Christopher Jolly 4554aad38e Update the translator for the string methods to add a couple more: Substring, IndexOf,FirstOrDefault,LastOrDefault 3 years ago
Christopher Jolly 05b10ea856 Type MApping: a long gets mapped to integer in Jet 3 years ago
Christopher Jolly b72b0aeb61 Support casting to Int64 3 years ago
Christopher Jolly fc6b407b36 Update version info for message for required OleDb and Odbc dependencies 3 years ago
Christopher Jolly ab7a424ef4 Fix up Design time services to work properly. Add-Migration command in VS will work now 3 years ago
Christopher Jolly 9843c0c8de Update DesignTimeService for Net 6 3 years ago
Christopher Jolly 81f6cbb254 revert to use our stringtypemapping to generate the sql literal. Some regex depends on using this format to pick the filename from the connection string 3 years ago
Christopher Jolly d100231ce9 [Tests]: Update tests 3 years ago
Christopher Jolly ef5c33cb74 [Fix]: No need for fancy conversion if there is a conversion expression on a Clr type which is an enum 3 years ago
Christopher Jolly ae21d832f1 Fix getting the schema for relations. Need both adox and DAO to get all fields 3 years ago
Christopher Jolly adbad89184 Fix check for unique 3 years ago
Christopher Jolly b78bbecf43 Do not generate SavePoint SQL. No-op 3 years ago
Christopher Jolly 58f0918d27 [Fix]: Use TryGetDefaultValue.. For an int property, GetDefaultValue will always return as a default 0 (a non null value), if TryGetDefaultValue fails. Thus the wrong ValueGenerationStrategy is returned 3 years ago
Christopher Jolly 093890fa66 [Fix]: Don't update the command to the trim'd version. If using an interceptor, it has already gotten the original commandText. Any comparisons between the actual result and the interceptor would fail 3 years ago
Christopher Jolly ee87572b2e Fix schema query: the ondelete and onupdate were added in the wrong order 3 years ago
Christopher Jolly 5341e45e80 Add translator for Jet Random 3 years ago
Christopher Jolly 2f2de12dd5 enable and fix tests 3 years ago
Christopher Jolly ed726d7478 [Fix]: Explicitly find DateTime in an IN expression and use the Jet formatting 3 years ago
Christopher Jolly b0624051b3 Fix check for correct type that this handles. Previous way of checking was overriding the Nullable Translator 3 years ago
Christopher Jolly 410ccb01c7 Add in support for .Parse methods on the simple types that support it (bool, int,double,datetime,byte,decimal,single) 3 years ago
Christopher Jolly 0bc5d04759 According to convention, if the property is the primary key and it is an integer, make it the identity column. This wasn't being set by default 3 years ago
Christopher Jolly 4eb1b0cdd8 Rewrite the COALESCE function into a form access can understand 3 years ago
Christopher Jolly b533695713 SqlExpressionFactory can't be used inside SqlGenerator so create the expressions manually. Fixes queries with conversions 3 years ago
Christopher Jolly ca0feb49d3 Add extension methods for the Fluent API IsClustered. Mainly for cross compaitiblity so that code written for multiple databases doesn't error. For Jet, the function won't do anything 3 years ago
Christopher Jolly 7dd239bea8 add compile fixes from upstream changes 3 years ago
Christopher Jolly 1f35ab88fd merge fixes from upstream 3 years ago
Laurents Meyer 6a8ccd27de
Fix transactions issues (#129)
* Fix active transaction support and disposed handling.

* Add transaction baseline tests.

* Fix transaction tests.
4 years ago
Laurents Meyer 3b6fee5a89
Disable savepoint API, because it is not supported by Jet. (#126) 4 years ago
Laurents Meyer a9455f81ea
Use double workaround only for DateTime default values if millisecond support has been enabled. (#127) 4 years ago
Laurents Meyer 120a47746a
[PORT] Improve `counter` type handling and add missing `counter` usage cases (#121)
* Improve counter type handling. (#112)

* Add missing counter usage cases.

* Adjust tests.
4 years ago
Laurents Meyer 09cfe3ac05
Add an IRelationalAnnotationProvider implementation. (#119) 4 years ago
Laurents Meyer 1eb7ec7793
Fix EXIST handling in regards to line breaks. (#117) (#118) 4 years ago
Laurents Meyer e9d4aef876
[PORT] Do not create Index-Operations with the same name as ForeignKey constraints (#115)
* In contrast to SQL Standard, MS Access will create an index together with a the FK constrains (#114)

According to https://docs.microsoft.com/en-us/office/client-developer/access/desktop-database-reference/constraint-clause-microsoft-access-sql
this can be deactivated, however creating an index with the same name as an FK still results in an runtime error, therefor the index creation operation is skipped

Co-authored-by: Michael Steinecke <m.p.steinecke@gmail.com>

* Update to 5.0 and cleanup code and comments.

Co-authored-by: Michael Steinecke <6099045+MichaelSteinecke@users.noreply.github.com>
Co-authored-by: Michael Steinecke <m.p.steinecke@gmail.com>
4 years ago