扩展LinqToEntities提供程序 [英] Extending LinqToEntities provider
问题描述
我正在尝试在字符串比较时在sql server(SQL COLLATE CLAUSE ...)上执行某些逻辑。我也试图保持流畅的api / poco / dbContext架构。所以我试着跟随...
$
包装linqtoEntity提供者:这并没有把我带到任何地方,因为我看到的所有例子都告诉你通过写作修改表达式树访客/ IQueryable等。
I am trying to execute some logic on sql server (SQL COLLATE CLAUSE...) when there are string comparisons. I am also trying to keep the fluent api/poco/dbContext based architecture. So i tried following ...
Wrapping the linqtoEntity provider : This did not lead me to anywhere since all examples i have seen tell you to modify the expression tree by writing a visitor/IQueryable etc.
似乎没有办法扩展/包装linqtoEntity提供程序以参与sql生成。
There doesnt seem to be a way to extend/wrap linqtoEntity provider to participate in sql generation.
这对我们来说是一笔大买卖,因为我们最终会写自己的orm(非常不幸)。
$
我在这里运气不好,有没有办法引入可以通过EntityFramework转换为sql的新Linq Operators / Extension方法?
This is a big deal for us, since we will end up writing our own orm ( which is very unfortunate)
Am i out of luck here and is there no way of introducing new Linq Operators/Extension methods that can get translated to sql by EntityFramework ?
推荐答案
Hi Seeker,
欢迎来到MSDN论坛。
您是否需要一个可以生成SQL的提供程序你希望吗?
执行linq to entities查询后,对象服务会将查询转换为命令树。然后将其传递给作为数据提供者的底层实体客户端。如果要生成自定义SQL,则为
可以编写数据提供程序。当您为Entity Framework编写提供程序时,必须将Entity Framework命令树转换为特定数据库可以理解的SQL,例如SQL Server的Transact-SQL或Oracle的PL / SQL。 ADO.NET数据提供程序
模型在.NET Framework中提供了一个公共托管接口,用于连接到数据存储并与之交互。请参阅此页:
http://msdn.microsoft.com/en-us/library/ee789835
这是一个实体框架示例提供程序:
http://archive.msdn.microsoft.com / EFSampleProvider
在这个示例中,您可以找到我认为对您有帮助的SQL生成部分。
此外,你可以看一下这篇文章:
http ://msdn.microsoft.com/en-us/magazine/cc301611.aspx
美好的一天。
这篇关于扩展LinqToEntities提供程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!