Comments (11)
hi,
this could be a nice feature. let me think about it, and i will integrate it in the next version.
cheers, esskar
from serialize.linq.
We'll, I'm thinking & playing with this idea and while it may work for simple & flat DTOs, it will be more difficult to achieve for complex cases:
- embedded DTO structures
- lists of objects
- embedded class definitions
In my case, I'm thinking now to reference in one way or another my server side domain from the client and use it to build queries...
from serialize.linq.
i have 2 ideas:
- build a mapper like automapper that maps 1 type to another type, but that would mean that you have to include the assembly of both types.
- ignore the original types when a custom type is passed to the serializer, and use property name matching, but that would mean that you need to know the type before deserialisation
from serialize.linq.
On options:
1 - I think the effort will not justify the outcome. Flexible Fluent APIs are not easy to build, there are many pieces to be tied together.
2 - This sounds more interesting. You have to know only the "destination" type on which expression is operating. A simple option on ExpressionSerializer to say to skip type names and include only property names will do it...
2nd option opens another interesting scenario: turning an incoming JSON doc (or a simple string) with a query definition and execute it as an Expression<>. Take say, a query string from a web request, execute it on a IQueryable and return results... Like OData :)
from serialize.linq.
I have the same problem.
Logically, DTO deserialized doesn't know mapped domain entity. But, we could add overloaded methods to .ToExpresion<>(), etc to make the replacement:
var domainExpression = expressionNode.ToExpression<Func<TResult , bool>>(stringDTO, stringDomainEntity);
Fixed comment .. Sorry, need TSource, TResult referenced...
A very good job, esskar!
from serialize.linq.
I added a Expression<TDelegate> ToExpression<TDelegate>(Func<ExpressionNode, Expression<TDelegate>> conversionFunction)
is this helpful in any way?
from serialize.linq.
it probably didn't.
but here is the deal. I made the ExpressionContext
class and also the ToExpression(ExpressionContext)
function public. I also extended ExpressionContext
by the function ResolveTypeName
. So what you need to do is implement your on ExpressionContext and override ResolveTypeName
to return types as you want them.
HTH
from serialize.linq.
Ok.
I was testing your code and could not find the method... lol
By the way, does not compile the latest version downloaded now (MemberInfoNodeList and other errors).
However, this improvement is not a critical point. I can use AutoMapper mapping (with internal mapped "errors") the resulting expression, after replacing namespaces dto to domain entities.
I understand that "ConcurrentDictionary <string, ParameterExpression>" in ExpressionContext dictionary is serialized as a string expression and its parameters. Is that true? Because if so, I think your solution is perfectly valid.
THANKS!
from serialize.linq.
ahhh, sorry for that. commited wrong.
fixed it now. please try again!
from serialize.linq.
I tried basically. Now we can modify the expression delegating or driving context.
Looks good!
from serialize.linq.
cool.
here is a blog post about it.
http://blog.esskar.de/articles/2013/1/serialize_linq_dto_and_business.html
Hope that helps.
from serialize.linq.
Related Issues (20)
- bug when using expressions that contain dynamic HOT 1
- Question on LambdaExpression serialization HOT 1
- .net 5.0 problem HOT 2
- Serialize expression when it is a property of a class? HOT 2
- Cannot Serialize Expression Converted From Func HOT 3
- How to Revice Post arguments in core 3.1
- Change of License HOT 6
- Expression.Default not supported in serialization HOT 2
- Question about deserialization security: HOT 1
- Need your help with other issue HOT 2
- "System.InvalidOperationException: Sequence contains no matching element" during SerializeText HOT 1
- Known type cannot be an interface
- Error converting type: Bug or implementation issue - please help HOT 3
- Undefined variable error when using ToString in lambda expression HOT 2
- Deploy the latest build to NuGet HOT 3
- Serialize Linq Expression not working - Workaround / Suggestion HOT 2
- Target framework net standard 2.0 & 2.1 HOT 3
- Changes from 2.x to 3.x HOT 2
- Error when serializing an expression with nested method calls
- Method serialization issue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serialize.linq.