SQL stored against model

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
damon.cognito
Posts: 50
Joined: Wed 22 Jul 2009 09:30

SQL stored against model

Post by damon.cognito » 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

Code: Select all

select <Table1.Field1> from <entity.Table1> left outer join <entity.Table2> on <Table1.Field2> = <Table2.Field2> where <Table2.Field1> = 1
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)?

Shalex
Site Admin
Posts: 8247
Joined: Thu 14 Aug 2008 12:44

Re: SQL stored against model

Post by Shalex » Thu 30 Mar 2017 15:59

damon.cognito wrote: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
1. You want all queries stored in DefiningQuery be executed (and rolled back with a report about errors), don't you? Please submit your suggestion at https://devart.uservoice.com/forums/386 ... -developer.
damon.cognito wrote: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
and for then to be validated on the save (and model save). If it had context help on the strong typed fields even better.
2. Please try using Entity SQL in QueryView: https://msdn.microsoft.com/en-us/librar ... .100).aspx. Is that what you need?

Post Reply