Skip to content

Commit 7bd57a7

Browse files
committed
Add MySqlComplexTypePropertyBuilderExtensions
1 parent 0bf88c5 commit 7bd57a7

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Copyright (c) Pomelo Foundation. All rights reserved.
2+
// Licensed under the MIT. See LICENSE in the project root for license information.
3+
4+
using JetBrains.Annotations;
5+
using Microsoft.EntityFrameworkCore.Metadata.Builders;
6+
using Microsoft.EntityFrameworkCore.Utilities;
7+
8+
// ReSharper disable once CheckNamespace
9+
namespace Microsoft.EntityFrameworkCore
10+
{
11+
/// <summary>
12+
/// MySQL specific extension methods for <see cref="ComplexTypePropertyBuilder" />.
13+
/// </summary>
14+
public static class MySqlComplexTypePropertyBuilderExtensions
15+
{
16+
#region Computed
17+
18+
/// <summary>
19+
/// Configures the charset for the property's column.
20+
/// </summary>
21+
/// <param name="propertyBuilder">The builder for the property being configured.</param>
22+
/// <param name="charSet">The name of the charset to configure for the property's column.</param>
23+
/// <returns>The same builder instance so that multiple calls can be chained.</returns>
24+
public static ComplexTypePropertyBuilder HasCharSet(
25+
[NotNull] this ComplexTypePropertyBuilder propertyBuilder,
26+
string charSet)
27+
{
28+
Check.NotNull(propertyBuilder, nameof(propertyBuilder));
29+
30+
var property = propertyBuilder.Metadata;
31+
property.SetCharSet(charSet);
32+
33+
return propertyBuilder;
34+
}
35+
36+
/// <summary>
37+
/// Configures the charset for the property's column.
38+
/// </summary>
39+
/// <param name="propertyBuilder">The builder for the property being configured.</param>
40+
/// <param name="charSet">The name of the charset to configure for the property's column.</param>
41+
/// <returns>The same builder instance so that multiple calls can be chained.</returns>
42+
public static ComplexTypePropertyBuilder<TProperty> HasCharSet<TProperty>(
43+
[NotNull] this ComplexTypePropertyBuilder<TProperty> propertyBuilder,
44+
string charSet)
45+
=> (ComplexTypePropertyBuilder<TProperty>)HasCharSet((ComplexTypePropertyBuilder)propertyBuilder, charSet);
46+
47+
48+
#endregion Computed
49+
}
50+
}

0 commit comments

Comments
 (0)