SQL stored against model
Posted: Tue 28 Mar 2017 11:01
In a previous response to me to get around a problem with poor information coming from the EF tree, you suggested writing an optimised SQL and storing it against the model. I really don't like this as one of the main reason we use EF is to make us aware of any issues in the code referencing renamed/removed tables/fields, or simple typos.
What would be good would be either
1. that when model is saved, each sql command text entries is run (each in a transaction which is aborted so as to not alter the DB) and any errors reported
2. You could write hybrid sqls command text entries using entity model substitutes, like
and for then to be validated on the save (and model save). If it had context help on the strong typed fields even better.
The second option is a bit of fantasy but the first should be fairly easy and quick to implement (together with a 'validate on model save' check box on sql command text entries dialog)?
What would be good would be either
1. that when model is saved, each sql command text entries is run (each in a transaction which is aborted so as to not alter the DB) and any errors reported
2. You could write hybrid sqls command text entries using entity model substitutes, like
Code: Select all
select <Table1.Field1> from <entity.Table1> left outer join <entity.Table2> on <Table1.Field2> = <Table2.Field2> where <Table2.Field1> = 1
The second option is a bit of fantasy but the first should be fairly easy and quick to implement (together with a 'validate on model save' check box on sql command text entries dialog)?