Comments (4)
Good idea! Syntax might be a bit verbose but also might be the least verbose possible.
from linqtosql2.
My first try was to build it with
x => x.Reads = x.Reads + 1
The problem was that Linq didn't support assignments in the inline version.
The biggest problem with that syntax is that it only allows updating a single property. If it's bound to SaveChanges it could simply allow multiple Update() to fix that. In my code the Update call triggers the Sql query. If using that approach I would either add a defered Set(propSelector, update) or create an overload for Update that can take a list of "ColumnModifications".
from linqtosql2.
It's indeed a tricky situation with which method to start the query, as you need more information appended after 'Update()' while it feels natural to start the update with 'Update()'. It is likely solvable with a myriad of lambdas but I've learned that although it works these kind of APIs aren't loved very much. Perhaps an UpdateSpecification object can be used and passed to the method? e.g.:
ctx.Customer.UpdateDirectly(c=>new UpdateSpecification() { /* init specification */});
With a specification it's possible to add whatever operations needed.
from linqtosql2.
CodeSmith DataContext extensions already do something like that and that's the syntax they use.
To remain consistent with SubmitChanges
, I would use .SubmitUpdate(c => new UpdateSpecification() { /* init specification */});
.
from linqtosql2.
Related Issues (20)
- Add proper eager loading to surpass limited LoadWith() support
- Add Spatial type support
- Optimize Context startup with Compatibility mode HOT 1
- Optimize Context startup by caching meta-data ourselves
- Omit null valued columns on insert so default values are inserted instead HOT 1
- Batch inserts HOT 5
- Delete multiple rows directly by Query HOT 1
- Expose the metadata in a nice API HOT 1
- Give me info about the current provider HOT 1
- Add support for entity splitting (multiple entity types, same table row)
- Add field exclude/include support for queries HOT 2
- Prevent phantom inserts of empty entities
- Remove SqlClient namespace dependency
- Add SQL Server 2012 specific paging support
- Add SQL Server NEWSEQUENTIALID() support
- Refactor SQL Server specific provider into separate assembly or namespace HOT 2
- Add Oracle support
- Add Sequence support to mappings and runtime
- Add Type Converter support to mappings and runtime
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 linqtosql2.