次の方法で共有


Generating the Data Service Client Library (ADO.NET Data Services)

You can use the Add Service Reference dialog in Visual Studio to add a reference to a data service. When you use this tool to add a reference to a data service in your client project, it performs the following actions:

  • Requests the metadata from the data service and interprets the returned metadata.

    Note

    The returned metadata is stored in the client project as an .edmx file. This .edmx file cannot be opened by using the Entity Data Model designer because it does not have the same format an .edmx file used by the Entity Framework. You can view this metadata file by using the XML editor or any text editor.

  • Generates a representation of the service as an entity container class that inherits from DataServiceContext. The behavior of this generated entity container class is similar to the entity container that the Entity Data Model tools generate. For more information, see Object Services Overview (Entity Framework).

  • Generates data classes for the data model types that it discovers in the service metadata.

  • Adds a reference to the System.Data.Services.Client assembly to the project.

For more information, see How to: Add a Data Service Reference (ADO.NET Data Services).

The client data service classes can also be generated by using the DataSvcUtil.exe tool at the command prompt. For more information, see How to: Manually Generate Client Data Service Classes (ADO.NET Data Services).

Important

The client data service classes that are generated by the Add Service Reference tool do not include the code that is required to bind data service data to controls. To be able to use the DataServiceCollection to bind this data to controls, you must instead use the DataSvcUtil.exe command-prompt utility to generate the client data service classes. For more information, see How to: Manually Generate Client Data Service Classes (ADO.NET Data Services).

Client Data Type Mapping

When you use the Add Service Reference dialog in Visual Studio or the DataSvcUtil.exe tool to generate client data classes that are based on the data model that is defined by the data service, the .NET Framework data types are mapped to the primitive types from the data model as follows:

Data model type

.NET Framework data type

Edm.Binary

Byte[]

Edm.Boolean

Boolean

Edm.Byte

Byte

Edm.DateTime

DateTime

Edm.Decimal

Decimal

Edm.Double

Double

Edm.Guid

Guid

Edm.Int16

Int16

Edm.Int32

Int32

Edm.Int64

Int64

Edm.SByte

SByte

Edm.Single

Single

Edm.String

String

See Also

Other Resources

Using a Data Service in a .NET Framework Application (ADO.NET Data Services)

Quickstart (ADO.NET Data Services)