-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for IsNew and GetType in LINQ provider and LambdaToJavasc…
…riptConverter (useful for ToString)
- Loading branch information
1 parent
3410e83
commit 644151a
Showing
12 changed files
with
327 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
644151a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IsNew
andGetType()
members supported inToStringExpression
This commit solves an old limitation of not being able to use
.IsNew
or.GetType()
members (Name
,FullName
,NiceName
.NicePluralName
or the newNewNiceName
) in LINQ provider.For normal queries, this methods are not particularly useful, (
IsNew
returns justfalse
), but they are very useful for definingToString
.The reasons this methods are particularly tricky is that they behave like constant C# sub-expressions - typically processed early in the LINQ provider using
ExpressionCleaner
- but they are discovered in a later stage - theQueryBinder
- when the expression tree is already a mixture of C# and SQL nodes.So after two failing attempts to move/generalize
ExpressionCleaner
, a little bit of code duplication made it work.Changes in default
Entity.ToString()
This is the old
ToString
defined in theEntity
class:And this is the new one:
Of course
IsNew
is erased-out from your SQL query, that ends up being something likeSELECT @p0 + t.Id FROM Ticket
with@p0="Ticket"
, this expression is completely translated to SQL so it can be used for filters and autocomplete.The new approach has a lot of benefits:
NiceName
/NewNiceName
theToString
function is localized to the current user culture, not the the culture of the last user that saved the entity.ToString
evaluates already to"Ticket 123"
instead of"Ticket (New)"
.ToStr
column needed by default. You can opt-in in your own Entity by having aToString
withoutAutoExpressionField
orToStirngExpression
for performance reasons.Also, some changes in
LambdaToJavascriptConverter
(the class that translate yourToString
definition to Javascript for client-side created entities) where needed to allow this new methods.How to Upgrade
There is no code change needed, but expect the Synchronizer / SQL Migrations to remove some unnecessary columns:
Enjoy!
644151a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent improvement! 👏 Great benefits 👌
644151a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job 👍