Git Product home page Git Product logo

Comments (11)

esskar avatar esskar commented on August 22, 2024

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.

vcaraulean avatar vcaraulean commented on August 22, 2024

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.

esskar avatar esskar commented on August 22, 2024

i have 2 ideas:

  1. 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.
  2. 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.

vcaraulean avatar vcaraulean commented on August 22, 2024

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.

 avatar commented on August 22, 2024

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.

esskar avatar esskar commented on August 22, 2024

I added a Expression<TDelegate> ToExpression<TDelegate>(Func<ExpressionNode, Expression<TDelegate>> conversionFunction)
is this helpful in any way?

from serialize.linq.

esskar avatar esskar commented on August 22, 2024

it probably didn't.

but here is the deal. I made the ExpressionContext class and also the ToExpression(ExpressionContext)function public. I also extended ExpressionContextby the function ResolveTypeName. So what you need to do is implement your on ExpressionContext and override ResolveTypeNameto return types as you want them.
HTH

from serialize.linq.

 avatar commented on August 22, 2024

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.

esskar avatar esskar commented on August 22, 2024

ahhh, sorry for that. commited wrong.
fixed it now. please try again!

from serialize.linq.

 avatar commented on August 22, 2024

I tried basically. Now we can modify the expression delegating or driving context.
Looks good!

from serialize.linq.

esskar avatar esskar commented on August 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.