.Net Editor Sql Square brackets fail request
.Net Editor Sql Square brackets fail request
Hello.
I have a problem from server side .net sql request via editor. I have table named User. Add it as usual with primary key Id.
new Editor(db, "dbo.User", ["dbo.User.Id"])
But User is functional word for sql request. So it doesn't work. I have first debug request.
SELECT COUNT( dbo.User.id ) as 'cnt' FROM [dbo].[User] WHERE (1=1)
Error in COUNT( dbo.User.id ) Request see User as specific word, not as a table name.
So I need to write square brackets around User and it will understand User as table name.
I change it in Editor request like
new Editor(db, "dbo.User", ["[dbo].[User].Id"])
and request go futher but last request has error
SELECT [[dbo]].[[User]].[ID] as '[dbo].[User].ID', [dbo].[User].[ID] as 'dbo.User.ID', ...
and has brackets twice.
How can I avoid it?
Replies
Try:
Editor will add the square brackets to protect the identifiers automatically).
Allan
in this case sometimes it doesn't work. if I have some left join with same column name it will give an error. I have dynamic table editor and don't know which columns will be. Solution for this was writing table name and schema
I have tested this again and now it work. I not sure why it changed. Before it didn't work without it. If I find this problem again - I will add problem here
Good to hear it is working at the moment. Thanks for the update.
Allan