Is there a dynamic Sql builder library for .Net? [closed]

感情迁移 提交于 2019-12-20 10:29:59

问题


Something like this.

http://code.google.com/p/squiggle-sql/wiki/Tutorial.

This is required for cases where It is required to build complex sql from the user input from UI. Currently in the project I am working is using String Manipulation which looks ugly and is difficult to maintain.


回答1:


Try DbExtensions, available as NuGet package.




回答2:


I was able to find a very good library for creating dynamic sql in .Net.

http://dynasql.codeplex.com/documentation




回答3:


Not that I am aware of (although that doesn't mean there definitely isn't).

What about Entity Framework? It allows the query to be built up and translates that to SQL against entities:

customers.OrderBy(c => c.Name).Skip(10).Take(20) 

Generates:

SELECT value c 
FROM NW.Customers AS c 
ORDER BY c.Name skip 10 limit 20; 



回答4:


Anything wrong with Linq-to-Sql?

var dc = new YourDataContext();
var query = dc.TableName.Where(x=>x.MatchesYourPredicate);
Console.WriteLine(dc.GetCommand(query).CommandText);



回答5:


I always build my own... it's quick and easy and you don't have to rely on 3rd-party libraries. Plus it helps you become that little bit more intimate with SQL.



来源:https://stackoverflow.com/questions/2671321/is-there-a-dynamic-sql-builder-library-for-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!