通用SQL生成.NET [英] Generic SQL builder .NET

查看:101
本文介绍了通用SQL生成.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找一种方式来写C#中的SQL语句,针对不同的供应商。 SQL语句差分典型的例子是在PostgreSQL中对比的极限= http://msdn.microsoft.com/en-us/library/ms189463.aspx">TOP在MSSQL 的。

I'm looking for a way to write an SQL statement in C# targeting different providers. A typical example of SQL statements differentiating is the LIMIT in PostgreSQL vs. TOP in MSSQL.

是解决SQL语法类似上面两个写的唯一途径if语句,这取决于提供商的用户选择或使用try catch语句流量控制( LIMIT没有工作,我会尽力TOP代替的)?我见过的 LINQ采取的方法,但我想知道如果一个人可以做这一点没有LINQ?

Is the only way to solve SQL-syntax like the two above to write if-statements depending on which provider the user selects or using try catch statements as flow control (LIMIT didn't work, I'll try TOP instead)? I've seen the LINQ Take method, but I'm wondering if one can do this without LINQ?

在换句话说,没有C#有我没能找到可以使用的一些通用的SQL Provider类?

In other words, does C# have some generic SQL Provider class that I have failed to find that can be used?

推荐答案

实体框架是能够针对不同的数据库。这将允许你写LINQ语句将与这两个数据库。你需要找到一个PostgreSQL提供的实体框架。有几种可供选择。

The Entity Framework is able to target different databases. This would allow you to write LINQ statements that would work with both databases. You would need to find a postgresql provider for the Entity Framework. There are several to choose from.

希望这有助于。

这篇关于通用SQL生成.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆