SQL Server Compact 与 LINQ to SQLSQL Server Compact and LINQ to SQL

SQL Server Compact 是随 Visual Studio 一起安装的默认数据库。SQL Server Compact is the default database installed with Visual Studio. 有关详细信息,请参阅 (Visual Studio) 使用 SQL Server Compact For more information, see Using SQL Server Compact (Visual Studio).

本主题概述了使用情况、配置、功能集和支持范围的主要区别 LINQ to SQLLINQ to SQLThis topic outlines the key differences in usage, configuration, feature sets, and scope of LINQ to SQLLINQ to SQL support.

SQL Server Compact 相对于 LINQ to SQL 的特性Characteristics of SQL Server Compact in Relation to LINQ to SQL

默认情况下,为所有 Visual Studio 版本安装 SQL Server Compact,因此在开发计算机上可用于的 LINQ to SQLLINQ to SQLBy default, SQL Server Compact is installed for all Visual Studio editions, and is therefore available on the development computer for use with LINQ to SQLLINQ to SQL. 但是,部署使用 SQL Server Compact 和的应用程序 LINQ to SQLLINQ to SQL 不同于 SQL Server 应用程序的应用程序。But deployment of an application that uses SQL Server Compact and LINQ to SQLLINQ to SQL differs from that for a SQL Server application. SQL Server Compact 不是 .NET Framework 的一部分,因此必须与应用程序一起打包或单独从 Microsoft 网站下载。SQL Server Compact is not a part of the .NET Framework, and therefore must be packaged with the application or downloaded separately from the Microsoft site.

请注意下列特性:Note the following characteristics:

  • SQL Server Compact 打包为可直接对数据库文件(扩展名为 .sdf)使用的 DLL。SQL Server Compact is packaged as a DLL that can be used against database files (.sdf extension) directly.

  • SQL Server Compact 与客户端应用程序在同一进程中运行。SQL Server Compact runs in the same process as the client application. 因此,与 SQL Server Compact 通信相比,可以大大提高与 SQL Server 通信的效率。The efficiency of communication with SQL Server Compact can therefore be significantly higher than communicating with SQL Server. 另一方面,SQL Server Compact 确实需要托管代码和非托管代码之间的互操作性,而这也会带来开销。On the other hand, SQL Server Compact does require interoperability between managed and unmanaged code with its attendant costs.

  • SQL Server Compact DLL 很小。The size of the SQL Server Compact DLL is small. 这一特征减小了应用程序的总大小。This feature reduces the overall application size.

  • LINQ to SQLLINQ to SQL 运行时和 SQLMetal 命令行工具支持 SQL Server Compact。The LINQ to SQLLINQ to SQL runtime and the SQLMetal command-line tool support SQL Server Compact.

  • 对象关系设计器不支持 SQL Server Compact。The Object Relational Designer does not support SQL Server Compact.

功能集Feature Set

SQL Server Compact 功能集比 SQL Server 功能集简单得多,这种方法可影响 LINQ to SQLLINQ to SQL 应用程序:The SQL Server Compact feature set is much simpler than the feature set of SQL Server in the following ways that can affect LINQ to SQLLINQ to SQL applications :

  • SQL Server Compact 不支持存储过程或视图。SQL Server Compact does not support stored procedures or views.

  • SQL Server Compact 仅支持部分数据类型和 SQL 函数。SQL Server Compact supports only a subset of data types and SQL functions.

  • SQL Server Compact 仅支持部分 SQL 构造。SQL Server Compact supports only a subset of SQL constructs.

  • SQL Server Compact 仅提供具有最基本功能的优化器。SQL Server Compact provides only a minimal optimizer. 有些查询可能会超时。It is possible that some queries might time out.

  • SQL Server Compact 不支持部分信任。SQL Server Compact does not support partial trust.

请参阅See also