实体框架与LINQ to SQL [英] Entity Framework vs LINQ to SQL

查看:131
本文介绍了实体框架与LINQ to SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在.NET v3.5 SP1已经被发布了(与VS2008 SP1一起),我们现在可以访问.NET实体框架。



我的问题是这个。当尝试使用实体框架和LINQ to SQL作为ORM时,有什么区别?



我理解的方式是实体框架(与LINQ一起使用时)到实体)是LINQ to SQL的大哥?如果是这样的话 - 它有什么优点? LINQ to SQL可以做什么呢?

解决方案

LINQ to SQL只支持1到1的映射的数据库表,视图,sprocs和Microsoft SQL Server中可用的功能。这是一个很好的API,用于快速数据访问构建到相对精心设计的SQL Server数据库。 LINQ2SQL首先使用C#3.0和.NET Framework 3.5发布。



LINQ to Entities(ADO.Net Entity Framework)是一个ORM(对象关系映射器)API,允许对象域模型的广泛定义及其与许多不同ADO.Net数据提供者的关系。因此,您可以混合和匹配一些不同的数据库供应商,应用程序服务器或协议来设计从各种表,源,服务等构建的对象的聚合混搭。ADO.Net Framework已发布.Net框架3.5 SP1。



这是一个关于MSDN的很好的介绍性文章:
向关系数据导入LINQ


Now that .NET v3.5 SP1 has been released (along with VS2008 SP1), we now have access to the .NET entity framework.

My question is this. When trying to decide between using the Entity Framework and LINQ to SQL as an ORM, what's the difference?

The way I understand it, the Entity Framework (when used with LINQ to Entities) is a 'big brother' to LINQ to SQL? If this is the case - what advantages does it have? What can it do that LINQ to SQL can't do on its own?

解决方案

LINQ to SQL only supports 1 to 1 mapping of database tables, views, sprocs and functions available in Microsoft SQL Server. It's a great API to use for quick data access construction to relatively well designed SQL Server databases. LINQ2SQL was first released with C# 3.0 and .Net Framework 3.5.

LINQ to Entities (ADO.Net Entity Framework) is an ORM (Object Relational Mapper) API which allows for a broad definition of object domain models and their relationships to many different ADO.Net data providers. As such, you can mix and match a number of different database vendors, application servers or protocols to design an aggregated mash-up of objects which are constructed from a variety of tables, sources, services, etc. ADO.Net Framework was released with the .Net Framework 3.5 SP1.

This is a good introductory article on MSDN: Introducing LINQ to Relational Data

这篇关于实体框架与LINQ to SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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