Releases: bazer/DataLinq
DataLinq v0.5.1 Release Notes
This release primarily focuses on critical fixes related to object equality, collection handling, source generator compatibility, and internal refactoring for improved robustness. It addresses key issues identified after the major v0.5.0 release.
🚀 Highlights & Fixes:
- Corrected Object Equality (
Equals
&GetHashCode
):- Breaking Change (Behavioral): The core equality comparison for entity instances (
Immutable
andMutable
) has been changed. Instead of comparing all property values, equality is now correctly based solely on the Primary Key(s). This aligns with standard ORM identity practices. - Two instances representing the same database row (same PK) will now be considered equal (
instance1.Equals(instance2)
returns true), regardless of whether other property values differ (e.g., due to one instance being stale). GetHashCode()
is now also based only on the Primary Key, ensuring stability, especially for mutable objects used in hash-based collections.
- Breaking Change (Behavioral): The core equality comparison for entity instances (
- Improved Handling of New/Unsaved Instances:
Mutable<T>
instances created vianew()
(before being saved to the database and receiving a real Primary Key, especially auto-increments) now use an internal, temporaryTransientId
(a Guid) forEquals
andGetHashCode
.- This allows distinct new instances to be correctly differentiated and managed in collections (
List
,HashSet
,Dictionary
keys,GroupBy
) before they are saved. - Important Note: As documented previously, the hash code of a mutable instance will change upon saving when it transitions from using the
TransientId
to using the database Primary Key. Avoid placing new instances in hash-based collections if you intend to save them later without removing/re-adding.
- Source Generator Compatibility:
- Downgraded the required
Microsoft.CodeAnalysis.CSharp
package version from 4.13 to 4.12. This resolves runtime loading errors for users with slightly older (but still common) Visual Studio 2022 / .NET SDK versions, the minimum supported version is now Visual Studio 2022 version 17.12 - Fixed a generator crash that occurred if only a database class was present without any table models.
- Downgraded the required
- Internal Refinements & Cleanup:
- Refactored relation handling internally for better encapsulation.
- Removed remnants of unsupported
ICustomTableModel
implementation. - Improved internal error handling.
- Cleaned up NuGet packaging configuration for clarity.
🐛 Other Bug Fixes:
- Resolved build/dependency issues in the source generator test project.
📝 Notes:
- This release addresses significant behavioral issues related to equality checks that could cause problems when using DataLinq entities in standard .NET collections or with LINQ operators like
GroupBy
. The new PK-based equality is the standard and correct approach for ORM entities. - The generator compatibility fix ensures wider usability across common developer environments.
DataLinq v0.5.0 Release Notes
This release marks a significant step forward for DataLinq, switching to using a source generator instead of reflection, improving performance by reducing memory allocations, major internal refactorings for robustness, and adding foundational features like logging and improved error handling. I also made substantial progress on documentation, including a new DocFX-based website.
🚨 Breaking Changes:
- Target Frameworks Updated: DataLinq now targets .NET 8.0 and .NET 9.0. Support for .NET 6 and .NET 7 has been removed. Please update your projects accordingly.
🚀 Highlights:
- Major work on a new Source Generator: A new source generator to replace the old Castle.Core based code.
- Generates two new classes Mutable[model] and Immutable[model].
- Supports C# nullable reference types (
#nullable enable
). - Correctly generates
required
properties on mutable models based on database constraints and default values. - Generates code respecting
[DefaultValue]
attributes from your models. - Improved error reporting and internal structure (moved to
DataLinq.Generators
project). - Reliably generates interfaces (e.g.,
IEmployee
) alongside model classes.
- Performance Boost & Reduced Allocations:
- Introduced
ReadOnlyAccess
for significantly faster, lower-allocation reads compared to using aTransaction
. - Optimized primary and foreign key handling using value type
IKey
structs (likeIntKey
,GuidKey
,CompositeKey
), reducing object allocations. - Improved performance for
Count()
andAny()
LINQ operations. - Optimized relation loading with
ImmutableRelation<T>
andImmutableForeignKey<T>
.
- Introduced
- Logging Integration: Added basic logging using
Microsoft.Extensions.Logging
. SQL commands, cache events, and transaction information can now be logged. - Enhanced Error Handling: Improved the internal
DLOptionFailure
system and exception messages for clearer diagnostics. - Documentation Website: Introduced a documentation website generated using DocFX for easier navigation and access to information. (See project README for link when available).
- Default Value Support: Models generated from databases now include
[DefaultValue]
attributes, and the source generator respects these when creating mutable classes. SQL generation also handles default values.
✨ Features & Enhancements:
- Added provider-specific SQL identifier escaping (e.g.,
`
for MySQL,"
for SQLite). - Refined mutation and save method workflows.
- Improved handling of
Nullable<T>
types internally and in LINQ queries.
🛠 Refactoring & Internal Improvements:
- Significant refactoring of core metadata classes (
DatabaseDefinition
,TableDefinition
,ModelDefinition
, etc.) for improved immutability, clarity, and reduced internal nullability warnings. - Refactored
RowCache
into its own class. - Cleaned up build system using
Directory.Build.props
. - Moved testing models to a dedicated
DataLinq.Tests.Models
project.
🐛 Bug Fixes:
- Fixed loading issues with nullable vs. non-nullable values.
- Fixed an issue where calling
Update
with no actual changes would cause an error. - Fixed mutable classes being incorrectly generated for database Views.
- Fixed incorrect column length parsing for MySQL numeric types.
- Fixed issues with multiple foreign key relations pointing to the same table.
- Fixed LINQ query translation involving nullable booleans.
- Fixed loading of nullable
DateOnly
values. - Addressed numerous nullability warnings throughout the codebase.
- Fixed preservation of original database model class names during generation/updates.
- Fixed various bugs related to SQLite compatibility (AutoIncrement, index types).
📦 Dependencies:
- Updated various NuGet package dependencies, including
MySqlConnector
,Microsoft.Data.Sqlite
,Microsoft.CodeAnalysis
, and testing libraries.
0.0.1 - Will probably eat your data
First release with basic functionality.
- Row cache
- Query builder
- Linq queries
- MySql support
- Database metadata
- Support for automatic creation of data models from database
- Working CRUD
- Transaction support
- Support for Select, Insert, Update, Delete, Where, Limit, OrderBy and nested And/Or
- Support for lazy loading of model properties