Skip to content

Commit 423bc0b

Browse files
committed
Create PrimitiveCollection top-level internal method.
1 parent d8a0276 commit 423bc0b

22 files changed

+433
-133
lines changed

src/EFCore.Cosmos/Extensions/CosmosPrimitiveCollectionBuilderExtensions.cs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using Microsoft.EntityFrameworkCore.Cosmos.Metadata.Internal;
5-
64
namespace Microsoft.EntityFrameworkCore;
75

86
/// <summary>
@@ -55,37 +53,4 @@ public static PrimitiveCollectionBuilder<TProperty> ToJsonProperty<TProperty>(
5553
this PrimitiveCollectionBuilder<TProperty> primitiveCollectionBuilder,
5654
string name)
5755
=> (PrimitiveCollectionBuilder<TProperty>)ToJsonProperty((PrimitiveCollectionBuilder)primitiveCollectionBuilder, name);
58-
59-
/// <summary>
60-
/// Configures this property to be the etag concurrency token.
61-
/// </summary>
62-
/// <remarks>
63-
/// See <see href="https://aka.ms/efcore-docs-modeling">Modeling entity types and relationships</see>, and
64-
/// <see href="https://aka.ms/efcore-docs-cosmos">Accessing Azure Cosmos DB with EF Core</see> for more information and examples.
65-
/// </remarks>
66-
/// <param name="primitiveCollectionBuilder">The builder for the property being configured.</param>
67-
/// <returns>The same builder instance so that multiple calls can be chained.</returns>
68-
public static PrimitiveCollectionBuilder IsETagConcurrency(this PrimitiveCollectionBuilder primitiveCollectionBuilder)
69-
{
70-
primitiveCollectionBuilder
71-
.IsConcurrencyToken()
72-
.ToJsonProperty("_etag")
73-
.ValueGeneratedOnAddOrUpdate();
74-
75-
return primitiveCollectionBuilder;
76-
}
77-
78-
/// <summary>
79-
/// Configures this property to be the etag concurrency token.
80-
/// </summary>
81-
/// <remarks>
82-
/// See <see href="https://aka.ms/efcore-docs-modeling">Modeling entity types and relationships</see>, and
83-
/// <see href="https://aka.ms/efcore-docs-cosmos">Accessing Azure Cosmos DB with EF Core</see> for more information and examples.
84-
/// </remarks>
85-
/// <typeparam name="TProperty">The type of the property being configured.</typeparam>
86-
/// <param name="primitiveCollectionBuilder">The builder for the property being configured.</param>
87-
/// <returns>The same builder instance so that multiple calls can be chained.</returns>
88-
public static PrimitiveCollectionBuilder<TProperty> IsETagConcurrency<TProperty>(
89-
this PrimitiveCollectionBuilder<TProperty> primitiveCollectionBuilder)
90-
=> (PrimitiveCollectionBuilder<TProperty>)IsETagConcurrency((PrimitiveCollectionBuilder)primitiveCollectionBuilder);
9156
}

src/EFCore/Metadata/Builders/ComplexPropertyBuilder.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,9 @@ public virtual ComplexTypePropertyBuilder Property(Type propertyType, string pro
215215
/// <returns>An object that can be used to configure the property.</returns>
216216
public virtual ComplexTypePrimitiveCollectionBuilder PrimitiveCollection(string propertyName)
217217
=> new(
218-
TypeBuilder.Property(
218+
TypeBuilder.PrimitiveCollection(
219219
Check.NotEmpty(propertyName, nameof(propertyName)),
220-
ConfigurationSource.Explicit)!.PrimitiveCollection(ConfigurationSource.Explicit)!.Metadata);
220+
ConfigurationSource.Explicit)!.Metadata);
221221

222222
/// <summary>
223223
/// Returns an object that can be used to configure a property of the complex type.
@@ -235,10 +235,9 @@ public virtual ComplexTypePrimitiveCollectionBuilder PrimitiveCollection(string
235235
/// <returns>An object that can be used to configure the property.</returns>
236236
public virtual ComplexTypePrimitiveCollectionBuilder<TProperty> PrimitiveCollection<TProperty>(string propertyName)
237237
=> new(
238-
TypeBuilder.Property(
238+
TypeBuilder.PrimitiveCollection(
239239
typeof(TProperty),
240-
Check.NotEmpty(propertyName, nameof(propertyName)), ConfigurationSource.Explicit)!
241-
.PrimitiveCollection(ConfigurationSource.Explicit)!.Metadata);
240+
Check.NotEmpty(propertyName, nameof(propertyName)), ConfigurationSource.Explicit)!.Metadata);
242241

243242
/// <summary>
244243
/// Returns an object that can be used to configure a property of the complex type.
@@ -256,10 +255,9 @@ public virtual ComplexTypePrimitiveCollectionBuilder<TProperty> PrimitiveCollect
256255
/// <returns>An object that can be used to configure the property.</returns>
257256
public virtual ComplexTypePrimitiveCollectionBuilder PrimitiveCollection(Type propertyType, string propertyName)
258257
=> new(
259-
TypeBuilder.Property(
258+
TypeBuilder.PrimitiveCollection(
260259
Check.NotNull(propertyType, nameof(propertyType)),
261-
Check.NotEmpty(propertyName, nameof(propertyName)), ConfigurationSource.Explicit)!
262-
.PrimitiveCollection(ConfigurationSource.Explicit)!.Metadata);
260+
Check.NotEmpty(propertyName, nameof(propertyName)), ConfigurationSource.Explicit)!.Metadata);
263261

264262
/// <summary>
265263
/// Returns an object that can be used to configure a property of the complex type.

src/EFCore/Metadata/Builders/ComplexPropertyBuilder`.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public virtual ComplexTypePropertyBuilder<TProperty> Property<TProperty>(Express
110110
/// </param>
111111
/// <returns>An object that can be used to configure the property.</returns>
112112
public virtual ComplexTypePrimitiveCollectionBuilder<TProperty> PrimitiveCollection<TProperty>(Expression<Func<TComplex, TProperty>> propertyExpression)
113-
=> new(TypeBuilder.Property(
113+
=> new(TypeBuilder.PrimitiveCollection(
114114
Check.NotNull(propertyExpression, nameof(propertyExpression)).GetMemberAccess(), ConfigurationSource.Explicit)!
115115
.Metadata);
116116

src/EFCore/Metadata/Builders/ComplexTypePrimitiveCollectionBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ public virtual ComplexTypePrimitiveCollectionBuilder HasField(string fieldName)
363363
/// </summary>
364364
/// <returns>A builder to configure the collection element type.</returns>
365365
public virtual ElementTypeBuilder ElementType()
366-
=> new((IMutableElementType)Builder.PrimitiveCollection(ConfigurationSource.Explicit)!.Metadata.GetElementType()!);
366+
=> new((IMutableElementType)Builder.Metadata.GetElementType()!);
367367

368368
/// <summary>
369369
/// Configures the elements of this collection.

src/EFCore/Metadata/Builders/EntityTypeBuilder.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,8 @@ public virtual PropertyBuilder Property(Type propertyType, string propertyName)
183183
/// <returns>An object that can be used to configure the property.</returns>
184184
public virtual PrimitiveCollectionBuilder PrimitiveCollection(string propertyName)
185185
=> new(
186-
Builder.Property(
187-
Check.NotEmpty(propertyName, nameof(propertyName)), ConfigurationSource.Explicit)!
188-
.PrimitiveCollection(ConfigurationSource.Explicit)!.Metadata);
186+
Builder.PrimitiveCollection(
187+
Check.NotEmpty(propertyName, nameof(propertyName)), ConfigurationSource.Explicit)!.Metadata);
189188

190189
/// <summary>
191190
/// Returns an object that can be used to configure a property of the entity type where that property represents
@@ -204,10 +203,9 @@ public virtual PrimitiveCollectionBuilder PrimitiveCollection(string propertyNam
204203
/// <returns>An object that can be used to configure the property.</returns>
205204
public virtual PrimitiveCollectionBuilder<TProperty> PrimitiveCollection<TProperty>(string propertyName)
206205
=> new(
207-
Builder.Property(
206+
Builder.PrimitiveCollection(
208207
typeof(TProperty),
209-
Check.NotEmpty(propertyName, nameof(propertyName)), ConfigurationSource.Explicit)!
210-
.PrimitiveCollection(ConfigurationSource.Explicit)!.Metadata);
208+
Check.NotEmpty(propertyName, nameof(propertyName)), ConfigurationSource.Explicit)!.Metadata);
211209

212210
/// <summary>
213211
/// Returns an object that can be used to configure a property of the entity type where that property represents
@@ -226,10 +224,9 @@ public virtual PrimitiveCollectionBuilder<TProperty> PrimitiveCollection<TProper
226224
/// <returns>An object that can be used to configure the property.</returns>
227225
public virtual PrimitiveCollectionBuilder PrimitiveCollection(Type propertyType, string propertyName)
228226
=> new(
229-
Builder.Property(
227+
Builder.PrimitiveCollection(
230228
Check.NotNull(propertyType, nameof(propertyType)),
231-
Check.NotEmpty(propertyName, nameof(propertyName)), ConfigurationSource.Explicit)!
232-
.PrimitiveCollection(ConfigurationSource.Explicit)!.Metadata);
229+
Check.NotEmpty(propertyName, nameof(propertyName)), ConfigurationSource.Explicit)!.Metadata);
233230

234231
/// <summary>
235232
/// Returns an object that can be used to configure a property of the entity type.

src/EFCore/Metadata/Builders/EntityTypeBuilder`.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ public virtual PropertyBuilder<TProperty> Property<TProperty>(Expression<Func<TE
164164
public virtual PrimitiveCollectionBuilder<TProperty> PrimitiveCollection<TProperty>(
165165
Expression<Func<TEntity, TProperty>> propertyExpression)
166166
=> new(
167-
Builder.Property(Check.NotNull(propertyExpression, nameof(propertyExpression)).GetMemberAccess(),
168-
ConfigurationSource.Explicit)!.PrimitiveCollection(ConfigurationSource.Explicit)!.Metadata);
167+
Builder.PrimitiveCollection(Check.NotNull(propertyExpression, nameof(propertyExpression)).GetMemberAccess(),
168+
ConfigurationSource.Explicit)!.Metadata);
169169

170170
/// <summary>
171171
/// Configures a complex property of the entity type.

src/EFCore/Metadata/Builders/IConventionPropertyBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,13 +545,13 @@ bool CanSetProviderValueComparer(
545545
/// any release. You should only use it directly in your code with extreme caution and knowing that
546546
/// doing so can result in application failures when updating to a new Entity Framework Core release.
547547
/// </summary>
548-
IConventionElementTypeBuilder? PrimitiveCollection(bool fromDataAnnotation = false);
548+
IConventionElementTypeBuilder? ElementType(bool fromDataAnnotation = false);
549549

550550
/// <summary>
551551
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
552552
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
553553
/// any release. You should only use it directly in your code with extreme caution and knowing that
554554
/// doing so can result in application failures when updating to a new Entity Framework Core release.
555555
/// </summary>
556-
bool CanSetPrimitiveCollection(bool fromDataAnnotation = false);
556+
bool CanSetElementType(bool fromDataAnnotation = false);
557557
}

src/EFCore/Metadata/Builders/OwnedNavigationBuilder.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,9 @@ public virtual PropertyBuilder Property(Type propertyType, string propertyName)
206206
public virtual PrimitiveCollectionBuilder PrimitiveCollection(string propertyName)
207207
=> UpdateBuilder(
208208
() => new PrimitiveCollectionBuilder(
209-
DependentEntityType.Builder.Property(
209+
DependentEntityType.Builder.PrimitiveCollection(
210210
Check.NotEmpty(propertyName, nameof(propertyName)),
211-
ConfigurationSource.Explicit)!
212-
.PrimitiveCollection(ConfigurationSource.Explicit)!.Metadata));
211+
ConfigurationSource.Explicit)!.Metadata));
213212

214213
/// <summary>
215214
/// Returns an object that can be used to configure a property of the owned type where that property represents
@@ -229,10 +228,9 @@ public virtual PrimitiveCollectionBuilder PrimitiveCollection(string propertyNam
229228
public virtual PrimitiveCollectionBuilder<TProperty> PrimitiveCollection<TProperty>(string propertyName)
230229
=> UpdateBuilder(
231230
() => new PrimitiveCollectionBuilder<TProperty>(
232-
DependentEntityType.Builder.Property(
231+
DependentEntityType.Builder.PrimitiveCollection(
233232
typeof(TProperty),
234-
Check.NotEmpty(propertyName, nameof(propertyName)), ConfigurationSource.Explicit)!
235-
.PrimitiveCollection(ConfigurationSource.Explicit)!.Metadata));
233+
Check.NotEmpty(propertyName, nameof(propertyName)), ConfigurationSource.Explicit)!.Metadata));
236234

237235
/// <summary>
238236
/// Returns an object that can be used to configure a property of the owned type where that property represents
@@ -251,10 +249,9 @@ public virtual PrimitiveCollectionBuilder<TProperty> PrimitiveCollection<TProper
251249
/// <returns>An object that can be used to configure the property.</returns>
252250
public virtual PrimitiveCollectionBuilder PrimitiveCollection(Type propertyType, string propertyName)
253251
=> new(
254-
DependentEntityType.Builder.Property(
252+
DependentEntityType.Builder.PrimitiveCollection(
255253
Check.NotNull(propertyType, nameof(propertyType)), Check.NotEmpty(propertyName, nameof(propertyName)),
256-
ConfigurationSource.Explicit)!
257-
.PrimitiveCollection(ConfigurationSource.Explicit)!.Metadata);
254+
ConfigurationSource.Explicit)!.Metadata);
258255

259256
/// <summary>
260257
/// Returns an object that can be used to configure a property of the entity type.

src/EFCore/Metadata/Builders/OwnedNavigationBuilder`.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ public virtual PropertyBuilder<TProperty> PrimitiveCollection<TProperty>(
116116
Expression<Func<TDependentEntity, TProperty>> propertyExpression)
117117
=> UpdateBuilder(
118118
() => new PropertyBuilder<TProperty>(
119-
DependentEntityType.Builder.Property(
119+
DependentEntityType.Builder.PrimitiveCollection(
120120
Check.NotNull(propertyExpression, nameof(propertyExpression)).GetMemberAccess(),
121-
ConfigurationSource.Explicit)!.PrimitiveCollection(ConfigurationSource.Explicit)!.Metadata));
121+
ConfigurationSource.Explicit)!.Metadata));
122122

123123
/// <summary>
124124
/// Returns an object that can be used to configure an existing navigation property

src/EFCore/Metadata/Builders/PrimitiveCollectionBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ public virtual PrimitiveCollectionBuilder HasField(string fieldName)
365365
/// </summary>
366366
/// <returns>A builder to configure the collection element type.</returns>
367367
public virtual ElementTypeBuilder ElementType()
368-
=> new((IMutableElementType)Builder.PrimitiveCollection(ConfigurationSource.Explicit)!.Metadata.GetElementType()!);
368+
=> new((IMutableElementType)Builder.Metadata.GetElementType()!);
369369

370370
/// <summary>
371371
/// Configures the elements of this collection.

0 commit comments

Comments
 (0)