Git Product home page Git Product logo

Comments (6)

esskar avatar esskar commented on August 22, 2024

I am not sure if i want to support private fields, because they are private!
Have to think about it!

from serialize.linq.

t-denis avatar t-denis commented on August 22, 2024

Consider the following scenario. The client builds the query against some stub data source, then the query is serialized and passed to the server. The server deserializes the query and applies it to the appropriate EF DbSet. From the client's prospective there is no difference if she uses a variable or a private field when she creates a Where clause:

var expression = Source.Where(row => row.Id == _rowId);

But in one case everything works fine, in other she gets a strange exception. The workaround for now:

var rowId = _rowId;
var expression = Source.Where(row => row.Id == rowId);

from serialize.linq.

esskar avatar esskar commented on August 22, 2024

Ok, i made it optional. On Serialization-Side you need to pass FactorySettings with AllowPrivateFieldAccess set to true, on Deserialzation-Side you need to set that property on the ExpressionContext

from serialize.linq.

t-denis avatar t-denis commented on August 22, 2024

Thank you. What do you think about providing two options:

  1. Member should be read on serialization and replaced with a constant (for multi-tier scenarios)
  2. Member should be read on runtime.
    Is it worth the time?

from serialize.linq.

esskar avatar esskar commented on August 22, 2024

Don't get it. Can you explain in detail?

from serialize.linq.

t-denis avatar t-denis commented on August 22, 2024

Lets assume we have an expression, that needs to be serialized:

var expression = People.Where(person => person.FirstName == firstName);

Right now the way that the expression is serialized depends on what 'firstName' is. If it is an instance field or a private static field, then the serialized expression will look like this (member access replaced with a constant):

People.Where(person => person.FirstName == "John");

If it is a public static field or a protected static field then the member access will be serialized 'as is':

People.Where(person => person.FirstName == SomeClass.firstName);

You can't pass that serialized expression to another tier, because SomeClass can be unreachable there.
Not sure why this happens, but you can see it in Issue54 tests. Probably this can be considered as an inconsistency - public/protected static fields should also be replaced with constants.
But I am guessing, what if user could specify how exactly an expression should be serialized? Can the option 2 (serialize 'as-is') be useful? Or the option 1 (replace with constants) is the only real-world scenario?

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.