diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/Modeling/AbpPropertyBuilderExtensions.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/Modeling/AbpPropertyBuilderExtensions.cs deleted file mode 100644 index 93aeb792da..0000000000 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/Modeling/AbpPropertyBuilderExtensions.cs +++ /dev/null @@ -1,110 +0,0 @@ -using System; -using System.Linq.Expressions; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.ChangeTracking; -using Microsoft.EntityFrameworkCore.Metadata.Builders; -using Newtonsoft.Json; - -namespace Volo.Abp.EntityFrameworkCore.Modeling -{ - public static class AbpPropertyBuilderExtensions - { - /// - /// Serialize and property attributes using json(JsonConvert). - /// - /// The builder for the property being configured. - /// Sets the custom ValueComparer for this property. - public static PropertyBuilder ConfigureJsonConversionWithValueComparer( - this PropertyBuilder propertyBuilder, - ValueComparer valueComparer) - { - propertyBuilder.HasConversion( - d => JsonConvert.SerializeObject(d, Formatting.None), - s => JsonConvert.DeserializeObject(s) - ) - .Metadata.SetValueComparer(valueComparer); - - return propertyBuilder; - } - - /// - /// Serialize and property attributes using json(JsonConvert). - /// - /// The builder for the property being configured. - /// - /// If true, then EF will use ValueComparer if the type - /// implements it. This is usually used when byte arrays act as keys. - /// - public static PropertyBuilder ConfigureJsonConversionWithValueComparer( - this PropertyBuilder propertyBuilder, - bool favorStructuralComparisons) - { - propertyBuilder.HasConversion( - d => JsonConvert.SerializeObject(d, Formatting.None), - s => JsonConvert.DeserializeObject(s) - ) - .Metadata.SetValueComparer(new ValueComparer(favorStructuralComparisons)); - - return propertyBuilder; - } - - /// - /// Serialize and property attributes using json(JsonConvert). - /// Creates a new ValueComparer with the given comparison expression. - /// A shallow copy will be used for the snapshot. - /// - /// The builder for the property being configured. - /// The comparison expression. - /// The associated hash code generator. - public static PropertyBuilder ConfigureJsonConversionWithValueComparer( - this PropertyBuilder propertyBuilder, - Expression> equalsExpression, - Expression> hashCodeExpression) - { - propertyBuilder.HasConversion( - d => JsonConvert.SerializeObject(d, Formatting.None), - s => JsonConvert.DeserializeObject(s) - ) - .Metadata.SetValueComparer(new ValueComparer( - equalsExpression, - hashCodeExpression)); - - return propertyBuilder; - } - - /// - /// Serialize and property attributes using json(JsonConvert). - /// - /// Creates a new ValueComparer with the given comparison and - /// snapshotting expressions. - /// - /// - /// Snapshotting is the process of creating a copy of the value into a snapshot so it can - /// later be compared to determine if it has changed. For some types, such as collections, - /// this needs to be a deep copy of the collection rather than just a shallow copy of the - /// reference. - /// - /// - /// The builder for the property being configured. - /// The comparison expression. - /// The associated hash code generator. - /// The snapshot expression. - public static PropertyBuilder ConfigureJsonConversionWithValueComparer( - this PropertyBuilder propertyBuilder, - Expression> equalsExpression, - Expression> hashCodeExpression, - Expression> snapshotExpression) - { - propertyBuilder.HasConversion( - d => JsonConvert.SerializeObject(d, Formatting.None), - s => JsonConvert.DeserializeObject(s) - ) - .Metadata.SetValueComparer(new ValueComparer( - equalsExpression, - hashCodeExpression, - snapshotExpression)); - - return propertyBuilder; - } - } -} \ No newline at end of file