DataServiceConfiguration 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
管理 WCF 数据服务的配置。
public ref class DataServiceConfiguration sealed : System::Data::Services::IDataServiceConfiguration
public sealed class DataServiceConfiguration : System.Data.Services.IDataServiceConfiguration
type DataServiceConfiguration = class
interface IDataServiceConfiguration
Public NotInheritable Class DataServiceConfiguration
Implements IDataServiceConfiguration
- 继承
-
DataServiceConfiguration
- 实现
示例
此示例显示了基于 Northwind 的数据服务的代码隐藏页,并授予对所选实体集的访问权限。
public class Northwind : DataService<NorthwindEntities>
{
// This method is called only once to initialize service-wide policies.
public static void InitializeService(DataServiceConfiguration config)
{
// Grant only the rights needed to support the client application.
config.SetEntitySetAccessRule("Orders", EntitySetRights.AllRead
| EntitySetRights.WriteMerge
| EntitySetRights.WriteReplace);
config.SetEntitySetAccessRule("Order_Details", EntitySetRights.AllRead
| EntitySetRights.AllWrite);
config.SetEntitySetAccessRule("Customers", EntitySetRights.AllRead);
}
}
Imports System.Data.Services
Imports System.Linq
Imports System.ServiceModel.Web
Public Class Northwind
Inherits DataService(Of NorthwindEntities)
' This method is called only once to initialize service-wide policies.
Public Shared Sub InitializeService(ByVal config As DataServiceConfiguration)
' Grant only the rights needed to support the client application.
config.SetEntitySetAccessRule("Orders", EntitySetRights.AllRead _
Or EntitySetRights.WriteMerge _
Or EntitySetRights.WriteReplace)
config.SetEntitySetAccessRule("Order_Details", EntitySetRights.AllRead _
Or EntitySetRights.AllWrite)
config.SetEntitySetAccessRule("Customers", EntitySetRights.AllRead)
End Sub
End Class
属性
| 名称 | 说明 |
|---|---|
| DataServiceBehavior |
获取一个 DataServiceBehavior 对象,该对象定义数据服务的其他行为。 |
| EnableTypeConversion |
获取或设置数据服务运行时是否应将有效负载中包含的类型转换为请求中指定的实际属性类型。 |
| MaxBatchCount |
获取或设置单个批处理中允许的最大更改集和查询操作数。 |
| MaxChangesetCount |
获取或设置单个更改集中可包含的最大更改数。 |
| MaxExpandCount |
获取或设置可以使用运算符在单个请求 |
| MaxExpandDepth |
获取或设置单个请求中可包含在 |
| MaxObjectCountOnInsert |
获取或设置要插入的最大对象数,这些对象可以包含在单个 POST 请求中。 |
| MaxResultsPerCollection |
获取或设置每个返回集合中的最大项数。 |
| UseVerboseErrors |
获取或设置数据服务是否应返回详细错误。 |
方法
| 名称 | 说明 |
|---|---|
| EnableTypeAccess(String) |
向数据服务运行时注册数据类型,以便自定义数据服务提供程序可以使用它。 |
| Equals(Object) |
确定指定的对象是否等于当前对象。 (继承自 Object) |
| GetHashCode() |
用作默认哈希函数。 (继承自 Object) |
| GetType() |
获取当前实例的 Type。 (继承自 Object) |
| MemberwiseClone() |
创建当前 Object的浅表副本。 (继承自 Object) |
| RegisterKnownType(Type) |
向数据服务识别的类型列表添加一个类型。 |
| SetEntitySetAccessRule(String, EntitySetRights) |
设置指定实体集资源的权限。 |
| SetEntitySetPageSize(String, Int32) |
设置实体集资源的最大页大小。 |
| SetServiceOperationAccessRule(String, ServiceOperationRights) |
设置指定服务操作的权限。 |
| ToString() |
返回一个表示当前对象的字符串。 (继承自 Object) |