Added support for filling properties not defined in model #83
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes #33.
This allows to fill entity properties not defined in model in
SELECT
queries usingInclude
methods.For example:
There will be a new column in SQL resultset with
Price * 0.9
value and this value will be assigned toArticle.PriceWithDiscount
property.VB.NET even allows to use nicer assignment syntax:
Every expression used in
Include
method will be added as an additional column (or multiple columns) to theSELECT
statement. If you don't need columns automatically added bySelectAll
method, you need to exclude them:You can include simple scalar values like, whole entity (model object),
ValueTuple
(although only VB.NET supports this) and anonymous objects (probably useful only in limited number of use cases due to casting issues).NOTE: if whole entity is included, it's always a "detached copy" unrelated to what would normally work using
SelectAll
method. This means:Exclude
method on that entity is ignored forInclude
entity instance (it always contains all columns defined in model configuration)Include
entity instanceInclude
entity instance is not used in any relationshipIf you don't need a "detached copy", it's probably just better to use
As
method to define an ad hoc relationship.NOTE:
Include
is only available "in automatic mode", i.e. whenSelectAll()
is used. It's not supported in custom selects, i.e. whenSelect(<expression>)
is used!