开发者

Are there any good .Net libraries for building arbitrary sql commands? Not relational data

开发者 https://www.devze.com 2022-12-30 00:36 出处:网络
I am looking for some library that takes the TextWriter approach to writing SQL commands (much like there is the HtmlTextWriter in .Net for writing html).I am NOT writing CRUD-type commands for relati

I am looking for some library that takes the TextWriter approach to writing SQL commands (much like there is the HtmlTextWriter in .Net for writing html). I am NOT writing CRUD-type commands for relational data, I am开发者_高级运维 writing arbitrary SQL (bulk inserts, table creation, creating backups, etc). Any suggestions are appreciated.


I'm not aware of any. I've thought about this myself in the past and considered writing one, but decided against it, because I don't think it really offers much value over and above just writing a plain SQL string. The drawback is, obviously, that it's harder to read the code and figure out what SQL is being constructed.

XML and HTML have much deeper levels of nesting than (typical) SQL queries. They also have a much more regular structure. That's why it makes sense to have a class to keep track of that structure. Doing the same in SQL would probably complicate the code more than it would simplify it.


Check this out: CodeSmith. I wouldn't say that this is the best out there, but those who have used it (not myself personally) have been very positive about it:

http://www.codesmithtools.com/


If your using SQL server, have a look at RedGate software as they have a range of tools that help you manage SQL server databases. I use the SSMS Addins that help you write SQL Statements then format them in a consistent way. It provides intellisense to make it faster to write SQL. They also have a whole range of other great productivity tools for Microsoft SQL Server.

Alternatively Linq might be a alternative as well as it created a good cross over between SQL and .net programming.


I'm afraid that writing arbitrary SQL (bulk inserts, table creation, creating backups, etc) depends heavily on the Db and the tools that it provides.

For example, creating backups use a syntax totally arbitrary and have nothing to do with the table creation syntax.

I'm not sure what are you trying to find, but I think that T-SQL (if you are using MS SQL server) is what you need.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号