Read only data context
Posted: Fri 04 Sep 2020 09:45
Hi.
I was trying to make my data context read only. Meaning that we can only query data from it, but not submit.
I found property ObjectTrackingEnabled, but I can't find a way of setting it to false by default.
I want to avoid doing
using (var db= new MyDataContext())
{
db.ObjectTrackingEnabled = false;
....
}
because it can be easily forgotten.
it seems that I can only set it to false during code generation, but that means changing default template and if I ever upgrade to a new version, my template will need to be updated manually or remain old, which is also not ideal.
any other ways i can make my dataContext read only?
I use LinqConnectContextModel
Thanks.
Olga
I was trying to make my data context read only. Meaning that we can only query data from it, but not submit.
I found property ObjectTrackingEnabled, but I can't find a way of setting it to false by default.
I want to avoid doing
using (var db= new MyDataContext())
{
db.ObjectTrackingEnabled = false;
....
}
because it can be easily forgotten.
it seems that I can only set it to false during code generation, but that means changing default template and if I ever upgrade to a new version, my template will need to be updated manually or remain old, which is also not ideal.
any other ways i can make my dataContext read only?
I use LinqConnectContextModel
Thanks.
Olga