rivantsov / vita

VITA Application Framework
MIT License
59 stars 15 forks source link

Session schedule insert or update #222

Closed jasonlaw closed 1 year ago

jasonlaw commented 1 year ago

Hi @rivantsov ,

May I know how to perform if exist then update, else insert with session schedule insert update?

Thanks.

rivantsov commented 1 year ago

I don't think that is supported, upsert operation (update/insert). Why don't you just before SaveChanges, run the check, if record exists - schedule update; if not - then insert

jasonlaw commented 1 year ago

May I know how to perform the insert without the select from? It looks like the script generated always expect a "select from", eg, insert into ... select from ..., while what I need is insert into .... values ....

Btw, is there a way to schedule a non query (native sql) command ?

rivantsov commented 1 year ago

Insert without Select - don't quite understand. You either make NewEntity or create InsertFromSelect using Linq. Schedule native query - I do not think it's possible. But look at App events related to session, you might hook to some event around SaveChanges and code native Sql manually

jasonlaw commented 1 year ago

I end up with NewEntity solution. Thanks!