Comments (6)
I am not sure if i want to support private fields, because they are private!
Have to think about it!
from serialize.linq.
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.
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.
Thank you. What do you think about providing two options:
- Member should be read on serialization and replaced with a constant (for multi-tier scenarios)
- Member should be read on runtime.
Is it worth the time?
from serialize.linq.
Don't get it. Can you explain in detail?
from serialize.linq.
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)
- 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.