Hello Radzen Team,
sometimes i need to compare various properties of model classes/objects before or after whenever they are updated. This is hard to do in Radzen.
It was great if the generated code for the Updatexxx Method in the DBService class will give the new item AND the actual database item into the OnxxxUpdated and OnAfterxxxUpdatec partial methods.
Like this:
partial void OnAngebotUploadDatumUpdated(Models.Trentdb.AngebotUploadDatum item, Models.Trentdb.AngebotUploadDatum itemToUpdate); partial void OnAfterAngebotUploadDatumUpdated(Models.Trentdb.AngebotUploadDatum item, Models.Trentdb.AngebotUploadDatum itemToUpdate); public async Task<Models.Trentdb.AngebotUploadDatum> UpdateAngebotUploadDatum(int? angebotUploadDataId, Models.Trentdb.AngebotUploadDatum angebotUploadDatum) { var itemToUpdate = context.AngebotUploadData .Where(i => i.AngebotUploadDataId == angebotUploadDataId) .FirstOrDefault(); if (itemToUpdate == null) { throw new Exception("Item no longer available"); } OnAngebotUploadDatumUpdated(angebotUploadDatum, itemToUpdate); var entryToUpdate = context.Entry(itemToUpdate); entryToUpdate.CurrentValues.SetValues(angebotUploadDatum); entryToUpdate.State = EntityState.Modified; context.SaveChanges(); OnAfterAngebotUploadDatumUpdated(angebotUploadDatum, itemToUpdate); return angebotUploadDatum; }
What do you think about it? It is helpful for so many things i think.
E.g. i like to implement a "History" of some kind of Changes made to the Data. This is very easy to do when new and old data can be compared in the partial methods.
And so much more...
Kind regards
Thomas