-
Notifications
You must be signed in to change notification settings - Fork 467
Expand file tree
/
Copy pathPrimitivePropertyConfiguration.cs
More file actions
78 lines (69 loc) · 2.73 KB
/
PrimitivePropertyConfiguration.cs
File metadata and controls
78 lines (69 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Reflection;
using Microsoft.OData.Edm;
namespace Microsoft.AspNet.OData.Builder
{
/// <summary>
/// Used to configure a primitive property of an entity type or complex type.
/// This configuration functionality is exposed by the model builder Fluent API, see <see cref="ODataModelBuilder"/>.
/// </summary>
public class PrimitivePropertyConfiguration : StructuralPropertyConfiguration
{
/// <summary>
/// Initializes a new instance of the <see cref="PrimitivePropertyConfiguration"/> class.
/// </summary>
/// <param name="property">The name of the property.</param>
/// <param name="declaringType">The declaring EDM type of the property.</param>
public PrimitivePropertyConfiguration(PropertyInfo property, StructuralTypeConfiguration declaringType)
:base(property, declaringType)
{
}
/// <summary>
/// Gets the type of this property.
/// </summary>
public override PropertyKind Kind
{
get { return PropertyKind.Primitive; }
}
/// <summary>
/// Gets the backing CLR type of this property type.
/// </summary>
public override Type RelatedClrType
{
get { return PropertyInfo.PropertyType; }
}
/// <summary>
/// Gets the target Edm type kind of this property. Call the extension methods to set this property.
/// </summary>
public EdmPrimitiveTypeKind? TargetEdmTypeKind { get; internal set; }
/// <summary>
/// Configures the property to be optional.
/// </summary>
/// <returns>Returns itself so that multiple calls can be chained.</returns>
public PrimitivePropertyConfiguration IsOptional()
{
OptionalProperty = true;
return this;
}
/// <summary>
/// Configures the property to be required.
/// </summary>
/// <returns>Returns itself so that multiple calls can be chained.</returns>
public PrimitivePropertyConfiguration IsRequired()
{
OptionalProperty = false;
return this;
}
/// <summary>
/// Configures the property to be used in concurrency checks. For OData this means to be part of the ETag.
/// </summary>
/// <returns>Returns itself so that multiple calls can be chained.</returns>
public PrimitivePropertyConfiguration IsConcurrencyToken()
{
ConcurrencyToken = true;
return this;
}
}
}