问题
What is the easiest way to support sql server rowversion during update?
I tried this:
db.UpdateOnly(u, f => new { f.Name, f.Description, f.Modified, f.ModifiedBy }, f => f.Version == u.Version && f.Id == u.Id);
but that fails miserably because it compares version as a Varchar(8000)
, go figure.
Not exactly the same but still a ServiceStack and OrmLite question:
What is the best way to eager load related entity descriptions? I've seen this but noticed the Join
changeset being checked in? This has lead to the POCO classes now having additional "Ignored" descriptions for each of the foreign keys.
回答1:
As RowVersion is a byte[]
field, it requires a parameterized support for Updates / Insert which have been added to ServiceStack.OrmLite in v3.9.37.
The Join
support is apart of a new Expression builder we're planning on adding to OrmLite, it's not ready yet. For eager loading you can use custom SQL or depending on your query you may be able to join the result sets in-memory using Linq2Objects.
来源:https://stackoverflow.com/questions/14761830/servicestack-ormlite-and-rowversion-support