diff --git a/src/EFCore.Design/Scaffolding/Internal/CSharpRuntimeModelCodeGenerator.cs b/src/EFCore.Design/Scaffolding/Internal/CSharpRuntimeModelCodeGenerator.cs
index 8a6f8f35c99..78b54d3c672 100644
--- a/src/EFCore.Design/Scaffolding/Internal/CSharpRuntimeModelCodeGenerator.cs
+++ b/src/EFCore.Design/Scaffolding/Internal/CSharpRuntimeModelCodeGenerator.cs
@@ -6,6 +6,7 @@
using Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
using Microsoft.EntityFrameworkCore.Design.Internal;
using Microsoft.EntityFrameworkCore.Internal;
+using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Query.Internal;
@@ -1179,18 +1180,7 @@ private void Create(
var valueComparerType = (Type?)property[CoreAnnotationNames.ValueComparerType];
if (valueComparerType != null)
{
- AddNamespace(valueComparerType, parameters.Namespaces);
-
- var valueComparerString = $"new {_code.Reference(valueComparerType)}()";
- if (property.ClrType.IsNullableValueType())
- {
- var valueComparerElementType = ((ValueComparer)Activator.CreateInstance(valueComparerType)!).Type;
- if (!valueComparerElementType.IsNullableValueType())
- {
- AddNamespace(typeof(NullableValueComparer<>), parameters.Namespaces);
- valueComparerString = $"new NullableValueComparer<{_code.Reference(valueComparerType)}>({valueComparerString})";
- }
- }
+ var valueComparerString = CreateValueComparerType(valueComparerType, property.ClrType, parameters);
mainBuilder.AppendLine(",")
.Append("valueComparer: ")
@@ -1240,11 +1230,13 @@ private void Create(
&& converter != null
&& property[CoreAnnotationNames.ValueConverter] != null
&& !parameters.ForNativeAot;
+ var typeMappingSet = false;
if (parameters.ForNativeAot
|| (shouldSetConverter && converter!.MappingHints != null))
{
shouldSetConverter = false;
+ typeMappingSet = true;
mainBuilder.Append(variableName).Append(".TypeMapping = ");
_annotationCodeGenerator.Create(property.GetTypeMapping(), property, propertyParameters);
mainBuilder.AppendLine(";");
@@ -1311,14 +1303,151 @@ private void Create(
.AppendLine(");");
}
+ var elementType = property.GetElementType();
+ if (elementType != null)
+ {
+ Check.DebugAssert(property.IsPrimitiveCollection, $"{property.Name} has an element type, but it's not a primitive collection.");
+ Create(elementType, typeMappingSet, propertyParameters);
+ }
+
CreateAnnotations(
property,
_annotationCodeGenerator.Generate,
- parameters with { TargetName = variableName });
+ propertyParameters);
mainBuilder.AppendLine();
}
+ private void Create(IElementType elementType, bool typeMappingSet, CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
+ {
+ var mainBuilder = parameters.MainBuilder;
+ var elementVariableName = _code.Identifier(parameters.TargetName + "ElementType", elementType, parameters.ScopeObjects, capitalize: false);
+ var elementParameters = parameters with { TargetName = elementVariableName };
+
+ mainBuilder
+ .Append("var ").Append(elementVariableName).Append(" = ")
+ .Append(parameters.TargetName).Append(".SetElementType(").IncrementIndent()
+ .Append(_code.Literal(elementType.ClrType));
+
+ if (elementType.IsNullable)
+ {
+ mainBuilder.AppendLine(",")
+ .Append("nullable: ")
+ .Append(_code.Literal(elementType.IsNullable));
+ }
+
+ if (elementType.GetMaxLength() != null)
+ {
+ mainBuilder.AppendLine(",")
+ .Append("maxLength: ")
+ .Append(_code.Literal(elementType.GetMaxLength()));
+ }
+
+ if (elementType.IsUnicode() != null)
+ {
+ mainBuilder.AppendLine(",")
+ .Append("unicode: ")
+ .Append(_code.Literal(elementType.IsUnicode()));
+ }
+
+ if (elementType.GetPrecision() != null)
+ {
+ mainBuilder.AppendLine(",")
+ .Append("precision: ")
+ .Append(_code.Literal(elementType.GetPrecision()));
+ }
+
+ if (elementType.GetScale() != null)
+ {
+ mainBuilder.AppendLine(",")
+ .Append("scale: ")
+ .Append(_code.Literal(elementType.GetScale()));
+ }
+
+ var providerClrType = elementType.GetProviderClrType();
+ if (providerClrType != null)
+ {
+ AddNamespace(providerClrType, parameters.Namespaces);
+ mainBuilder.AppendLine(",")
+ .Append("providerClrType: ")
+ .Append(_code.Literal(providerClrType));
+ }
+
+ var jsonValueReaderWriterType = (Type?)elementType[CoreAnnotationNames.JsonValueReaderWriterType];
+ if (jsonValueReaderWriterType != null)
+ {
+ mainBuilder.AppendLine(",")
+ .Append("jsonValueReaderWriter: ");
+ CSharpRuntimeAnnotationCodeGenerator.CreateJsonValueReaderWriter(jsonValueReaderWriterType, parameters, _code);
+ }
+
+ mainBuilder
+ .AppendLine(");")
+ .DecrementIndent();
+
+ var converter = elementType.FindTypeMapping()?.Converter;
+ var shouldSetConverter = providerClrType == null
+ && converter != null
+ && elementType[CoreAnnotationNames.ValueConverter] != null
+ && !parameters.ForNativeAot;
+
+ if (parameters.ForNativeAot
+ || (shouldSetConverter && converter!.MappingHints != null))
+ {
+ shouldSetConverter = false;
+ mainBuilder.Append(elementVariableName).Append(".TypeMapping = ");
+
+ if (typeMappingSet)
+ {
+ mainBuilder.Append(parameters.TargetName).Append(".TypeMapping.ElementTypeMapping");
+ }
+ else
+ {
+ _annotationCodeGenerator.Create(elementType.GetTypeMapping(), elementParameters);
+ }
+
+ mainBuilder.AppendLine(";");
+ }
+
+ if (shouldSetConverter)
+ {
+ mainBuilder.Append(elementVariableName).Append(".SetValueConverter(");
+ _annotationCodeGenerator.Create(converter!, parameters);
+ mainBuilder.AppendLine(");");
+ }
+
+ var valueComparer = elementType.GetValueComparer();
+ var typeMappingComparer = elementType.GetTypeMapping().Comparer;
+ if ((!parameters.ForNativeAot || valueComparer != typeMappingComparer)
+ && (parameters.ForNativeAot || elementType[CoreAnnotationNames.ValueComparer] != null))
+ {
+ SetValueComparer(valueComparer, typeMappingComparer, nameof(CoreTypeMapping.Comparer), elementParameters);
+ }
+
+ CreateAnnotations(
+ elementType,
+ _annotationCodeGenerator.Generate,
+ elementParameters);
+ }
+
+ private string CreateValueComparerType(Type valueComparerType, Type clrType, CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
+ {
+ AddNamespace(valueComparerType, parameters.Namespaces);
+
+ var valueComparerString = $"new {_code.Reference(valueComparerType)}()";
+ if (clrType.IsNullableValueType())
+ {
+ var valueComparerElementType = ((ValueComparer)Activator.CreateInstance(valueComparerType)!).Type;
+ if (!valueComparerElementType.IsNullableValueType())
+ {
+ AddNamespace(typeof(NullableValueComparer<>), parameters.Namespaces);
+ valueComparerString = $"new NullableValueComparer<{_code.Reference(valueComparerType)}>({valueComparerString})";
+ }
+ }
+
+ return valueComparerString;
+ }
+
private void SetValueComparer(
ValueComparer valueComparer,
ValueComparer typeMappingComparer,
diff --git a/src/EFCore.Relational/Storage/RelationalTypeMapping.cs b/src/EFCore.Relational/Storage/RelationalTypeMapping.cs
index f2081c607f5..d2db50c5740 100644
--- a/src/EFCore.Relational/Storage/RelationalTypeMapping.cs
+++ b/src/EFCore.Relational/Storage/RelationalTypeMapping.cs
@@ -572,12 +572,6 @@ public virtual DbParameter CreateParameter(
if (nullable.HasValue)
{
- Check.DebugAssert(
- nullable.Value
- || !direction.HasFlag(ParameterDirection.Input)
- || value != null,
- "Null value in a non-nullable input parameter");
-
parameter.IsNullable = nullable.Value;
}
diff --git a/src/EFCore.Relational/Update/ReaderModificationCommandBatch.cs b/src/EFCore.Relational/Update/ReaderModificationCommandBatch.cs
index 81b989d2045..0e0611667be 100644
--- a/src/EFCore.Relational/Update/ReaderModificationCommandBatch.cs
+++ b/src/EFCore.Relational/Update/ReaderModificationCommandBatch.cs
@@ -393,7 +393,7 @@ public override async Task ExecuteAsync(
await ConsumeAsync(dataReader, cancellationToken).ConfigureAwait(false);
}
- catch (Exception ex) when (ex is not DbUpdateException and not OperationCanceledException)
+ catch (Exception ex) when (ex is not DbUpdateException and not OperationCanceledException and not UnreachableException)
{
throw new DbUpdateException(
RelationalStrings.UpdateStoreException,
diff --git a/src/EFCore/Design/Internal/CSharpRuntimeAnnotationCodeGenerator.cs b/src/EFCore/Design/Internal/CSharpRuntimeAnnotationCodeGenerator.cs
index ef13010eb6b..dbf79e7930c 100644
--- a/src/EFCore/Design/Internal/CSharpRuntimeAnnotationCodeGenerator.cs
+++ b/src/EFCore/Design/Internal/CSharpRuntimeAnnotationCodeGenerator.cs
@@ -140,6 +140,24 @@ public virtual void Generate(IServiceProperty property, CSharpRuntimeAnnotationC
GenerateSimpleAnnotations(parameters);
}
+ ///
+ public virtual void Generate(IElementType elementType, CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
+ {
+ if (!parameters.IsRuntime)
+ {
+ var annotations = parameters.Annotations;
+ foreach (var (key, _) in annotations)
+ {
+ if (CoreAnnotationNames.AllNames.Contains(key))
+ {
+ annotations.Remove(key);
+ }
+ }
+ }
+
+ GenerateSimpleAnnotations(parameters);
+ }
+
///
public virtual void Generate(IKey key, CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
{
diff --git a/src/EFCore/Design/Internal/ICSharpRuntimeAnnotationCodeGenerator.cs b/src/EFCore/Design/Internal/ICSharpRuntimeAnnotationCodeGenerator.cs
index 82a6e67bcb1..66f5a7b630b 100644
--- a/src/EFCore/Design/Internal/ICSharpRuntimeAnnotationCodeGenerator.cs
+++ b/src/EFCore/Design/Internal/ICSharpRuntimeAnnotationCodeGenerator.cs
@@ -55,6 +55,13 @@ public interface ICSharpRuntimeAnnotationCodeGenerator
/// Additional parameters used during code generation.
void Generate(IServiceProperty property, CSharpRuntimeAnnotationCodeGeneratorParameters parameters);
+ ///
+ /// Generates code to create the given annotations.
+ ///
+ /// The element type to which the annotations are applied.
+ /// Additional parameters used during code generation.
+ void Generate(IElementType elementType, CSharpRuntimeAnnotationCodeGeneratorParameters parameters);
+
///
/// Generates code to create the given annotations.
///
diff --git a/src/EFCore/Metadata/Conventions/RuntimeModelConvention.cs b/src/EFCore/Metadata/Conventions/RuntimeModelConvention.cs
index 110d239f076..3e4c032235b 100644
--- a/src/EFCore/Metadata/Conventions/RuntimeModelConvention.cs
+++ b/src/EFCore/Metadata/Conventions/RuntimeModelConvention.cs
@@ -63,7 +63,8 @@ protected virtual RuntimeModel Create(IModel model)
var elementType = property.GetElementType();
if (elementType != null)
{
- var runtimeElementType = Create(runtimeProperty, elementType, property.IsPrimitiveCollection);
+ Check.DebugAssert(property.IsPrimitiveCollection, $"{property.Name} has an element type, but it's not a primitive collection.");
+ var runtimeElementType = Create(runtimeProperty, elementType);
CreateAnnotations(
elementType, runtimeElementType, static (convention, annotations, source, target, runtime) =>
convention.ProcessElementTypeAnnotations(annotations, source, target, runtime));
@@ -410,7 +411,7 @@ private static RuntimeProperty Create(IProperty property, RuntimeTypeBase runtim
typeMapping: property.GetTypeMapping(),
sentinel: property.Sentinel);
- private static RuntimeElementType Create(RuntimeProperty runtimeProperty, IElementType element, bool primitiveCollection)
+ private static RuntimeElementType Create(RuntimeProperty runtimeProperty, IElementType element)
=> runtimeProperty.SetElementType(
element.ClrType,
element.IsNullable,
@@ -422,8 +423,7 @@ private static RuntimeElementType Create(RuntimeProperty runtimeProperty, IEleme
element.GetValueConverter(),
element.GetValueComparer(),
element.GetJsonValueReaderWriter(),
- element.GetTypeMapping(),
- primitiveCollection);
+ element.GetTypeMapping());
///
/// Updates the property annotations that will be set on the read-only object.
@@ -539,7 +539,8 @@ private RuntimeComplexProperty Create(IComplexProperty complexProperty, RuntimeT
var elementType = property.GetElementType();
if (elementType != null)
{
- var runtimeElementType = Create(runtimeProperty, elementType, property.IsPrimitiveCollection);
+ Check.DebugAssert(property.IsPrimitiveCollection, $"{property.Name} has an element type, but it's not a primitive collection.");
+ var runtimeElementType = Create(runtimeProperty, elementType);
CreateAnnotations(
elementType, runtimeElementType, static (convention, annotations, source, target, runtime) =>
convention.ProcessElementTypeAnnotations(annotations, source, target, runtime));
diff --git a/src/EFCore/Metadata/IElementType.cs b/src/EFCore/Metadata/IElementType.cs
index e4e6637257d..b74d6740d02 100644
--- a/src/EFCore/Metadata/IElementType.cs
+++ b/src/EFCore/Metadata/IElementType.cs
@@ -19,4 +19,10 @@ public interface IElementType : IReadOnlyElementType, IAnnotatable
[DebuggerStepThrough]
get => (IProperty)((IReadOnlyElementType)this).CollectionProperty;
}
+
+ ///
+ /// Gets the for this property.
+ ///
+ /// The comparer.
+ new ValueComparer GetValueComparer();
}
diff --git a/src/EFCore/Metadata/Internal/ElementType.cs b/src/EFCore/Metadata/Internal/ElementType.cs
index 1cc3e906426..0b05492bdf9 100644
--- a/src/EFCore/Metadata/Internal/ElementType.cs
+++ b/src/EFCore/Metadata/Internal/ElementType.cs
@@ -895,6 +895,16 @@ void IMutableElementType.SetProviderClrType(Type? providerClrType)
providerClrType,
fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);
+ ///
+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
+ /// any release. You should only use it directly in your code with extreme caution and knowing that
+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
+ ///
+ [DebuggerStepThrough]
+ ValueComparer IElementType.GetValueComparer()
+ => GetValueComparer()!;
+
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
diff --git a/src/EFCore/Metadata/RuntimeElementType.cs b/src/EFCore/Metadata/RuntimeElementType.cs
index 74a78f2d229..3ccbc731ea3 100644
--- a/src/EFCore/Metadata/RuntimeElementType.cs
+++ b/src/EFCore/Metadata/RuntimeElementType.cs
@@ -1,6 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
+using System.Runtime.CompilerServices;
+using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Storage.Json;
@@ -15,10 +17,10 @@ namespace Microsoft.EntityFrameworkCore.Metadata;
public class RuntimeElementType : RuntimeAnnotatableBase, IElementType
{
private readonly bool _isNullable;
- private readonly ValueConverter? _valueConverter;
- private readonly ValueComparer? _valueComparer;
+ private ValueConverter? _valueConverter;
+ private ValueComparer? _valueComparer;
private readonly JsonValueReaderWriter? _jsonValueReaderWriter;
- private readonly CoreTypeMapping? _typeMapping;
+ private CoreTypeMapping? _typeMapping;
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -90,12 +92,27 @@ public RuntimeElementType(
public virtual bool IsNullable
=> _isNullable;
+ ///
+ /// Gets or sets the type mapping for this element type.
+ ///
+ /// The type mapping.
+ public virtual CoreTypeMapping TypeMapping
+ {
+ get => NonCapturingLazyInitializer.EnsureInitialized(
+ ref _typeMapping, (IElementType)this,
+ static elementType =>
+ RuntimeFeature.IsDynamicCodeSupported
+ ? elementType.CollectionProperty.DeclaringType.Model.GetModelDependencies().TypeMappingSource.FindMapping(elementType)!
+ : throw new InvalidOperationException(CoreStrings.NativeAotNoCompiledModel));
+ set => _typeMapping = value;
+ }
+
///
/// Returns the type mapping for elements of the collection.
///
/// The type mapping, or if none was found.
public virtual CoreTypeMapping? FindTypeMapping()
- => _typeMapping;
+ => TypeMapping;
///
/// Gets the maximum length of data that is allowed in elements of the collection. For example, if the element type is
@@ -143,13 +160,33 @@ public virtual bool IsNullable
public virtual ValueConverter? GetValueConverter()
=> _valueConverter;
+ ///
+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
+ /// any release. You should only use it directly in your code with extreme caution and knowing that
+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
+ ///
+ [EntityFrameworkInternal]
+ public virtual void SetValueConverter(ValueConverter converter)
+ => _valueConverter = converter;
+
///
/// Gets the custom for elements of the collection.
///
/// The comparer, or if none has been set.
[DebuggerStepThrough]
public virtual ValueComparer? GetValueComparer()
- => _valueComparer;
+ => _valueComparer ?? _typeMapping?.Comparer;
+
+ ///
+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
+ /// any release. You should only use it directly in your code with extreme caution and knowing that
+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
+ ///
+ [EntityFrameworkInternal]
+ public virtual ValueComparer SetComparer(ValueComparer valueComparer)
+ => _valueComparer = valueComparer;
///
/// Gets the type that the elements of the collection will be converted to before being sent to the database provider.
@@ -213,11 +250,6 @@ bool IReadOnlyElementType.IsNullable
int? IReadOnlyElementType.GetScale()
=> (int?)this[CoreAnnotationNames.Scale];
- ///
- [DebuggerStepThrough]
- ValueConverter? IReadOnlyElementType.GetValueConverter()
- => _valueConverter;
-
///
[DebuggerStepThrough]
Type? IReadOnlyElementType.GetProviderClrType()
@@ -227,4 +259,9 @@ bool IReadOnlyElementType.IsNullable
[DebuggerStepThrough]
CoreTypeMapping IReadOnlyElementType.FindTypeMapping()
=> FindTypeMapping()!;
+
+ ///
+ [DebuggerStepThrough]
+ ValueComparer IElementType.GetValueComparer()
+ => GetValueComparer()!;
}
diff --git a/src/EFCore/Metadata/RuntimeProperty.cs b/src/EFCore/Metadata/RuntimeProperty.cs
index 52f382e4e5c..c453438c746 100644
--- a/src/EFCore/Metadata/RuntimeProperty.cs
+++ b/src/EFCore/Metadata/RuntimeProperty.cs
@@ -128,7 +128,7 @@ public virtual void SetSentinelFromProviderValue(object? providerValue)
/// A value indicating whether or not the property can persist Unicode characters.
/// The precision of data that is allowed in this property.
/// The scale of data that is allowed in this property.
- ///
+ ///
/// The type that the property value will be converted to before being sent to the database provider.
///
/// The custom set for this property.
@@ -144,12 +144,11 @@ public virtual RuntimeElementType SetElementType(
bool? unicode = null,
int? precision = null,
int? scale = null,
- Type? providerPropertyType = null,
+ Type? providerClrType = null,
ValueConverter? valueConverter = null,
ValueComparer? valueComparer = null,
JsonValueReaderWriter? jsonValueReaderWriter = null,
- CoreTypeMapping? typeMapping = null,
- bool primitiveCollection = false)
+ CoreTypeMapping? typeMapping = null)
{
var elementType = new RuntimeElementType(
clrType,
@@ -159,7 +158,7 @@ public virtual RuntimeElementType SetElementType(
unicode,
precision,
scale,
- providerPropertyType,
+ providerClrType,
valueConverter,
valueComparer,
jsonValueReaderWriter,
@@ -167,7 +166,7 @@ public virtual RuntimeElementType SetElementType(
SetAnnotation(CoreAnnotationNames.ElementType, elementType);
- IsPrimitiveCollection = primitiveCollection;
+ IsPrimitiveCollection = true;
return elementType;
}
diff --git a/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/Basic_cosmos_model/DataEntityType.cs b/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/Basic_cosmos_model/DataEntityType.cs
index 09e7d8fa59c..075516e0072 100644
--- a/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/Basic_cosmos_model/DataEntityType.cs
+++ b/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/Basic_cosmos_model/DataEntityType.cs
@@ -244,6 +244,9 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
clrType: typeof(Dictionary),
jsonValueReaderWriter: new CosmosTypeMappingSource.PlaceholderJsonStringKeyedDictionaryReaderWriter(
JsonInt32ReaderWriter.Instance)));
+ var listElementType = list.SetElementType(typeof(Dictionary),
+ nullable: true);
+ listElementType.TypeMapping = list.TypeMapping.ElementTypeMapping;
var map = runtimeEntityType.AddProperty(
"Map",
diff --git a/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/BigModel/ManyTypesEntityType.cs b/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/BigModel/ManyTypesEntityType.cs
index 7deabfede83..0908f41f867 100644
--- a/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/BigModel/ManyTypesEntityType.cs
+++ b/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/BigModel/ManyTypesEntityType.cs
@@ -47,7 +47,6 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(CompiledModelTestBase.ManyTypesId),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("Id", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
- valueGenerated: ValueGenerated.OnAdd,
afterSaveBehavior: PropertySaveBehavior.Throw,
valueConverter: new CompiledModelTestBase.ManyTypesIdConverter());
id.SetGetter(
@@ -60,7 +59,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
id.SetMaterializationSetter(
(CompiledModelTestBase.ManyTypes entity, CompiledModelTestBase.ManyTypesId value) => ManyTypesUnsafeAccessors.Id(entity) = value);
id.SetAccessors(
- CompiledModelTestBase.ManyTypesId (InternalEntityEntry entry) => (entry.FlaggedAsStoreGenerated(0) ? entry.ReadStoreGeneratedValue(0) : (entry.FlaggedAsTemporary(0) && ManyTypesUnsafeAccessors.Id(((CompiledModelTestBase.ManyTypes)(entry.Entity))).Equals(default(CompiledModelTestBase.ManyTypesId)) ? entry.ReadTemporaryValue(0) : ManyTypesUnsafeAccessors.Id(((CompiledModelTestBase.ManyTypes)(entry.Entity))))),
+ CompiledModelTestBase.ManyTypesId (InternalEntityEntry entry) => ManyTypesUnsafeAccessors.Id(((CompiledModelTestBase.ManyTypes)(entry.Entity))),
CompiledModelTestBase.ManyTypesId (InternalEntityEntry entry) => ManyTypesUnsafeAccessors.Id(((CompiledModelTestBase.ManyTypes)(entry.Entity))),
CompiledModelTestBase.ManyTypesId (InternalEntityEntry entry) => entry.ReadOriginalValue(id, 0),
CompiledModelTestBase.ManyTypesId (InternalEntityEntry entry) => entry.ReadRelationshipSnapshotValue(id, 0),
@@ -70,7 +69,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
originalValueIndex: 0,
shadowIndex: -1,
relationshipIndex: 0,
- storeGenerationIndex: 0);
+ storeGenerationIndex: -1);
id.TypeMapping = CosmosTypeMapping.Default.Clone(
comparer: new ValueComparer(
bool (CompiledModelTestBase.ManyTypesId v1, CompiledModelTestBase.ManyTypesId v2) => v1.Equals(v2),
@@ -228,6 +227,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
bool (bool v) => v),
clrType: typeof(bool),
jsonValueReaderWriter: JsonBoolReaderWriter.Instance));
+ var boolArrayElementType = boolArray.SetElementType(typeof(bool));
+ boolArrayElementType.TypeMapping = boolArray.TypeMapping.ElementTypeMapping;
var boolNestedCollection = runtimeEntityType.AddProperty(
"BoolNestedCollection",
@@ -303,6 +304,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
bool (bool v) => v),
clrType: typeof(bool),
jsonValueReaderWriter: JsonBoolReaderWriter.Instance)));
+ var boolNestedCollectionElementType = boolNestedCollection.SetElementType(typeof(bool[]));
+ boolNestedCollectionElementType.TypeMapping = boolNestedCollection.TypeMapping.ElementTypeMapping;
var boolReadOnlyCollection = runtimeEntityType.AddProperty(
"BoolReadOnlyCollection",
@@ -361,6 +364,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
bool (bool v) => v),
clrType: typeof(bool),
jsonValueReaderWriter: JsonBoolReaderWriter.Instance));
+ var boolReadOnlyCollectionElementType = boolReadOnlyCollection.SetElementType(typeof(bool));
+ boolReadOnlyCollectionElementType.TypeMapping = boolReadOnlyCollection.TypeMapping.ElementTypeMapping;
var boolToStringConverterProperty = runtimeEntityType.AddProperty(
"BoolToStringConverterProperty",
@@ -758,6 +763,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
char (char v) => v),
clrType: typeof(char),
jsonValueReaderWriter: JsonCharReaderWriter.Instance));
+ var charArrayElementType = charArray.SetElementType(typeof(char));
+ charArrayElementType.TypeMapping = charArray.TypeMapping.ElementTypeMapping;
var charNestedCollection = runtimeEntityType.AddProperty(
"CharNestedCollection",
@@ -833,6 +840,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
char (char v) => v),
clrType: typeof(char),
jsonValueReaderWriter: JsonCharReaderWriter.Instance)));
+ var charNestedCollectionElementType = charNestedCollection.SetElementType(typeof(char[]));
+ charNestedCollectionElementType.TypeMapping = charNestedCollection.TypeMapping.ElementTypeMapping;
var charToStringConverterProperty = runtimeEntityType.AddProperty(
"CharToStringConverterProperty",
@@ -1413,6 +1422,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
decimal (decimal v) => v),
clrType: typeof(decimal),
jsonValueReaderWriter: JsonDecimalReaderWriter.Instance));
+ var decimalArrayElementType = decimalArray.SetElementType(typeof(decimal));
+ decimalArrayElementType.TypeMapping = decimalArray.TypeMapping.ElementTypeMapping;
var decimalNumberToBytesConverterProperty = runtimeEntityType.AddProperty(
"DecimalNumberToBytesConverterProperty",
@@ -1614,6 +1625,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
double (double v) => v),
clrType: typeof(double),
jsonValueReaderWriter: JsonDoubleReaderWriter.Instance));
+ var doubleArrayElementType = doubleArray.SetElementType(typeof(double));
+ doubleArrayElementType.TypeMapping = doubleArray.TypeMapping.ElementTypeMapping;
var doubleNumberToBytesConverterProperty = runtimeEntityType.AddProperty(
"DoubleNumberToBytesConverterProperty",
@@ -2707,6 +2720,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
float (float v) => v),
clrType: typeof(float),
jsonValueReaderWriter: JsonFloatReaderWriter.Instance));
+ var floatArrayElementType = floatArray.SetElementType(typeof(float));
+ floatArrayElementType.TypeMapping = floatArray.TypeMapping.ElementTypeMapping;
var guid = runtimeEntityType.AddProperty(
"Guid",
@@ -3103,6 +3118,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
short (short v) => v),
clrType: typeof(short),
jsonValueReaderWriter: JsonInt16ReaderWriter.Instance));
+ var int16ArrayElementType = int16Array.SetElementType(typeof(short));
+ int16ArrayElementType.TypeMapping = int16Array.TypeMapping.ElementTypeMapping;
var int32 = runtimeEntityType.AddProperty(
"Int32",
@@ -3204,6 +3221,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
int (int v) => v),
clrType: typeof(int),
jsonValueReaderWriter: JsonInt32ReaderWriter.Instance));
+ var int32ArrayElementType = int32Array.SetElementType(typeof(int));
+ int32ArrayElementType.TypeMapping = int32Array.TypeMapping.ElementTypeMapping;
var int32NestedCollection = runtimeEntityType.AddProperty(
"Int32NestedCollection",
@@ -3279,6 +3298,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
int (int v) => v),
clrType: typeof(int),
jsonValueReaderWriter: JsonInt32ReaderWriter.Instance)));
+ var int32NestedCollectionElementType = int32NestedCollection.SetElementType(typeof(int[]));
+ int32NestedCollectionElementType.TypeMapping = int32NestedCollection.TypeMapping.ElementTypeMapping;
var int32ReadOnlyCollection = runtimeEntityType.AddProperty(
"Int32ReadOnlyCollection",
@@ -3337,6 +3358,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
int (int v) => v),
clrType: typeof(int),
jsonValueReaderWriter: JsonInt32ReaderWriter.Instance));
+ var int32ReadOnlyCollectionElementType = int32ReadOnlyCollection.SetElementType(typeof(int));
+ int32ReadOnlyCollectionElementType.TypeMapping = int32ReadOnlyCollection.TypeMapping.ElementTypeMapping;
var int64 = runtimeEntityType.AddProperty(
"Int64",
@@ -3438,6 +3461,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
long (long v) => v),
clrType: typeof(long),
jsonValueReaderWriter: JsonInt64ReaderWriter.Instance));
+ var int64ArrayElementType = int64Array.SetElementType(typeof(long));
+ int64ArrayElementType.TypeMapping = int64Array.TypeMapping.ElementTypeMapping;
var int64NestedCollection = runtimeEntityType.AddProperty(
"Int64NestedCollection",
@@ -3531,6 +3556,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
long (long v) => v),
clrType: typeof(long),
jsonValueReaderWriter: JsonInt64ReaderWriter.Instance))));
+ var int64NestedCollectionElementType = int64NestedCollection.SetElementType(typeof(IList));
+ int64NestedCollectionElementType.TypeMapping = int64NestedCollection.TypeMapping.ElementTypeMapping;
var int8 = runtimeEntityType.AddProperty(
"Int8",
@@ -3632,6 +3659,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
sbyte (sbyte v) => v),
clrType: typeof(sbyte),
jsonValueReaderWriter: JsonSByteReaderWriter.Instance));
+ var int8ArrayElementType = int8Array.SetElementType(typeof(sbyte));
+ int8ArrayElementType.TypeMapping = int8Array.TypeMapping.ElementTypeMapping;
var int8NestedCollection = runtimeEntityType.AddProperty(
"Int8NestedCollection",
@@ -3725,6 +3754,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
sbyte (sbyte v) => v),
clrType: typeof(sbyte),
jsonValueReaderWriter: JsonSByteReaderWriter.Instance))));
+ var int8NestedCollectionElementType = int8NestedCollection.SetElementType(typeof(sbyte[][]));
+ int8NestedCollectionElementType.TypeMapping = int8NestedCollection.TypeMapping.ElementTypeMapping;
var intNumberToBytesConverterProperty = runtimeEntityType.AddProperty(
"IntNumberToBytesConverterProperty",
@@ -3980,6 +4011,10 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
bool (bool v) => v),
clrType: typeof(bool),
jsonValueReaderWriter: JsonBoolReaderWriter.Instance));
+ var nullableBoolArrayElementType = nullableBoolArray.SetElementType(typeof(bool?),
+ nullable: true);
+ nullableBoolArrayElementType.TypeMapping = nullableBoolArray.TypeMapping.ElementTypeMapping;
+ nullableBoolArrayElementType.SetComparer(new NullableValueComparer(nullableBoolArrayElementType.TypeMapping.Comparer));
var nullableBytes = runtimeEntityType.AddProperty(
"NullableBytes",
@@ -4132,6 +4167,10 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
char (char v) => v),
clrType: typeof(char),
jsonValueReaderWriter: JsonCharReaderWriter.Instance));
+ var nullableCharArrayElementType = nullableCharArray.SetElementType(typeof(char?),
+ nullable: true);
+ nullableCharArrayElementType.TypeMapping = nullableCharArray.TypeMapping.ElementTypeMapping;
+ nullableCharArrayElementType.SetComparer(new NullableValueComparer(nullableCharArrayElementType.TypeMapping.Comparer));
var nullableDateOnly = runtimeEntityType.AddProperty(
"NullableDateOnly",
@@ -4325,6 +4364,10 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
decimal (decimal v) => v),
clrType: typeof(decimal),
jsonValueReaderWriter: JsonDecimalReaderWriter.Instance));
+ var nullableDecimalArrayElementType = nullableDecimalArray.SetElementType(typeof(decimal?),
+ nullable: true);
+ nullableDecimalArrayElementType.TypeMapping = nullableDecimalArray.TypeMapping.ElementTypeMapping;
+ nullableDecimalArrayElementType.SetComparer(new NullableValueComparer(nullableDecimalArrayElementType.TypeMapping.Comparer));
var nullableDouble = runtimeEntityType.AddProperty(
"NullableDouble",
@@ -4428,6 +4471,10 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
double (double v) => v),
clrType: typeof(double),
jsonValueReaderWriter: JsonDoubleReaderWriter.Instance));
+ var nullableDoubleArrayElementType = nullableDoubleArray.SetElementType(typeof(double?),
+ nullable: true);
+ nullableDoubleArrayElementType.TypeMapping = nullableDoubleArray.TypeMapping.ElementTypeMapping;
+ nullableDoubleArrayElementType.SetComparer(new NullableValueComparer(nullableDoubleArrayElementType.TypeMapping.Comparer));
var nullableEnum16 = runtimeEntityType.AddProperty(
"NullableEnum16",
@@ -5347,6 +5394,10 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
float (float v) => v),
clrType: typeof(float),
jsonValueReaderWriter: JsonFloatReaderWriter.Instance));
+ var nullableFloatArrayElementType = nullableFloatArray.SetElementType(typeof(float?),
+ nullable: true);
+ nullableFloatArrayElementType.TypeMapping = nullableFloatArray.TypeMapping.ElementTypeMapping;
+ nullableFloatArrayElementType.SetComparer(new NullableValueComparer(nullableFloatArrayElementType.TypeMapping.Comparer));
var nullableGuid = runtimeEntityType.AddProperty(
"NullableGuid",
@@ -5550,6 +5601,10 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
short (short v) => v),
clrType: typeof(short),
jsonValueReaderWriter: JsonInt16ReaderWriter.Instance));
+ var nullableInt16ArrayElementType = nullableInt16Array.SetElementType(typeof(short?),
+ nullable: true);
+ nullableInt16ArrayElementType.TypeMapping = nullableInt16Array.TypeMapping.ElementTypeMapping;
+ nullableInt16ArrayElementType.SetComparer(new NullableValueComparer(nullableInt16ArrayElementType.TypeMapping.Comparer));
var nullableInt32 = runtimeEntityType.AddProperty(
"NullableInt32",
@@ -5653,6 +5708,10 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
int (int v) => v),
clrType: typeof(int),
jsonValueReaderWriter: JsonInt32ReaderWriter.Instance));
+ var nullableInt32ArrayElementType = nullableInt32Array.SetElementType(typeof(int?),
+ nullable: true);
+ nullableInt32ArrayElementType.TypeMapping = nullableInt32Array.TypeMapping.ElementTypeMapping;
+ nullableInt32ArrayElementType.SetComparer(new NullableValueComparer(nullableInt32ArrayElementType.TypeMapping.Comparer));
var nullableInt32NestedCollection = runtimeEntityType.AddProperty(
"NullableInt32NestedCollection",
@@ -5728,6 +5787,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
int (int v) => v),
clrType: typeof(int),
jsonValueReaderWriter: JsonInt32ReaderWriter.Instance)));
+ var nullableInt32NestedCollectionElementType = nullableInt32NestedCollection.SetElementType(typeof(int?[]));
+ nullableInt32NestedCollectionElementType.TypeMapping = nullableInt32NestedCollection.TypeMapping.ElementTypeMapping;
var nullableInt64 = runtimeEntityType.AddProperty(
"NullableInt64",
@@ -5831,6 +5892,10 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
long (long v) => v),
clrType: typeof(long),
jsonValueReaderWriter: JsonInt64ReaderWriter.Instance));
+ var nullableInt64ArrayElementType = nullableInt64Array.SetElementType(typeof(long?),
+ nullable: true);
+ nullableInt64ArrayElementType.TypeMapping = nullableInt64Array.TypeMapping.ElementTypeMapping;
+ nullableInt64ArrayElementType.SetComparer(new NullableValueComparer(nullableInt64ArrayElementType.TypeMapping.Comparer));
var nullableInt64NestedCollection = runtimeEntityType.AddProperty(
"NullableInt64NestedCollection",
@@ -5924,6 +5989,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
long (long v) => v),
clrType: typeof(long),
jsonValueReaderWriter: JsonInt64ReaderWriter.Instance))));
+ var nullableInt64NestedCollectionElementType = nullableInt64NestedCollection.SetElementType(typeof(long?[][]));
+ nullableInt64NestedCollectionElementType.TypeMapping = nullableInt64NestedCollection.TypeMapping.ElementTypeMapping;
var nullableInt8 = runtimeEntityType.AddProperty(
"NullableInt8",
@@ -6027,6 +6094,10 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
sbyte (sbyte v) => v),
clrType: typeof(sbyte),
jsonValueReaderWriter: JsonSByteReaderWriter.Instance));
+ var nullableInt8ArrayElementType = nullableInt8Array.SetElementType(typeof(sbyte?),
+ nullable: true);
+ nullableInt8ArrayElementType.TypeMapping = nullableInt8Array.TypeMapping.ElementTypeMapping;
+ nullableInt8ArrayElementType.SetComparer(new NullableValueComparer(nullableInt8ArrayElementType.TypeMapping.Comparer));
var nullablePhysicalAddress = runtimeEntityType.AddProperty(
"NullablePhysicalAddress",
@@ -6177,6 +6248,9 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
string (string v) => v),
clrType: typeof(string),
jsonValueReaderWriter: JsonStringReaderWriter.Instance));
+ var nullableStringArrayElementType = nullableStringArray.SetElementType(typeof(string),
+ nullable: true);
+ nullableStringArrayElementType.TypeMapping = nullableStringArray.TypeMapping.ElementTypeMapping;
var nullableStringNestedCollection = runtimeEntityType.AddProperty(
"NullableStringNestedCollection",
@@ -6252,6 +6326,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
string (string v) => v),
clrType: typeof(string),
jsonValueReaderWriter: JsonStringReaderWriter.Instance)));
+ var nullableStringNestedCollectionElementType = nullableStringNestedCollection.SetElementType(typeof(string[]));
+ nullableStringNestedCollectionElementType.TypeMapping = nullableStringNestedCollection.TypeMapping.ElementTypeMapping;
var nullableTimeOnly = runtimeEntityType.AddProperty(
"NullableTimeOnly",
@@ -6445,6 +6521,10 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
ushort (ushort v) => v),
clrType: typeof(ushort),
jsonValueReaderWriter: JsonUInt16ReaderWriter.Instance));
+ var nullableUInt16ArrayElementType = nullableUInt16Array.SetElementType(typeof(ushort?),
+ nullable: true);
+ nullableUInt16ArrayElementType.TypeMapping = nullableUInt16Array.TypeMapping.ElementTypeMapping;
+ nullableUInt16ArrayElementType.SetComparer(new NullableValueComparer(nullableUInt16ArrayElementType.TypeMapping.Comparer));
var nullableUInt32 = runtimeEntityType.AddProperty(
"NullableUInt32",
@@ -6548,6 +6628,10 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
uint (uint v) => v),
clrType: typeof(uint),
jsonValueReaderWriter: JsonUInt32ReaderWriter.Instance));
+ var nullableUInt32ArrayElementType = nullableUInt32Array.SetElementType(typeof(uint?),
+ nullable: true);
+ nullableUInt32ArrayElementType.TypeMapping = nullableUInt32Array.TypeMapping.ElementTypeMapping;
+ nullableUInt32ArrayElementType.SetComparer(new NullableValueComparer(nullableUInt32ArrayElementType.TypeMapping.Comparer));
var nullableUInt64 = runtimeEntityType.AddProperty(
"NullableUInt64",
@@ -6651,6 +6735,10 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
ulong (ulong v) => v),
clrType: typeof(ulong),
jsonValueReaderWriter: JsonUInt64ReaderWriter.Instance));
+ var nullableUInt64ArrayElementType = nullableUInt64Array.SetElementType(typeof(ulong?),
+ nullable: true);
+ nullableUInt64ArrayElementType.TypeMapping = nullableUInt64Array.TypeMapping.ElementTypeMapping;
+ nullableUInt64ArrayElementType.SetComparer(new NullableValueComparer(nullableUInt64ArrayElementType.TypeMapping.Comparer));
var nullableUInt8 = runtimeEntityType.AddProperty(
"NullableUInt8",
@@ -6754,6 +6842,10 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
byte (byte v) => v),
clrType: typeof(byte),
jsonValueReaderWriter: JsonByteReaderWriter.Instance));
+ var nullableUInt8ArrayElementType = nullableUInt8Array.SetElementType(typeof(byte?),
+ nullable: true);
+ nullableUInt8ArrayElementType.TypeMapping = nullableUInt8Array.TypeMapping.ElementTypeMapping;
+ nullableUInt8ArrayElementType.SetComparer(new NullableValueComparer(nullableUInt8ArrayElementType.TypeMapping.Comparer));
var nullableUri = runtimeEntityType.AddProperty(
"NullableUri",
@@ -7049,6 +7141,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
string (string v) => v),
clrType: typeof(string),
jsonValueReaderWriter: JsonStringReaderWriter.Instance));
+ var stringArrayElementType = stringArray.SetElementType(typeof(string));
+ stringArrayElementType.TypeMapping = stringArray.TypeMapping.ElementTypeMapping;
var stringNestedCollection = runtimeEntityType.AddProperty(
"StringNestedCollection",
@@ -7124,6 +7218,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
string (string v) => v),
clrType: typeof(string),
jsonValueReaderWriter: JsonStringReaderWriter.Instance)));
+ var stringNestedCollectionElementType = stringNestedCollection.SetElementType(typeof(string[]));
+ stringNestedCollectionElementType.TypeMapping = stringNestedCollection.TypeMapping.ElementTypeMapping;
var stringReadOnlyCollection = runtimeEntityType.AddProperty(
"StringReadOnlyCollection",
@@ -7182,6 +7278,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
string (string v) => v),
clrType: typeof(string),
jsonValueReaderWriter: JsonStringReaderWriter.Instance));
+ var stringReadOnlyCollectionElementType = stringReadOnlyCollection.SetElementType(typeof(string));
+ stringReadOnlyCollectionElementType.TypeMapping = stringReadOnlyCollection.TypeMapping.ElementTypeMapping;
var stringToBoolConverterProperty = runtimeEntityType.AddProperty(
"StringToBoolConverterProperty",
@@ -8248,6 +8346,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
ushort (ushort v) => v),
clrType: typeof(ushort),
jsonValueReaderWriter: JsonUInt16ReaderWriter.Instance));
+ var uInt16ArrayElementType = uInt16Array.SetElementType(typeof(ushort));
+ uInt16ArrayElementType.TypeMapping = uInt16Array.TypeMapping.ElementTypeMapping;
var uInt32 = runtimeEntityType.AddProperty(
"UInt32",
@@ -8349,6 +8449,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
uint (uint v) => v),
clrType: typeof(uint),
jsonValueReaderWriter: JsonUInt32ReaderWriter.Instance));
+ var uInt32ArrayElementType = uInt32Array.SetElementType(typeof(uint));
+ uInt32ArrayElementType.TypeMapping = uInt32Array.TypeMapping.ElementTypeMapping;
var uInt64 = runtimeEntityType.AddProperty(
"UInt64",
@@ -8450,6 +8552,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
ulong (ulong v) => v),
clrType: typeof(ulong),
jsonValueReaderWriter: JsonUInt64ReaderWriter.Instance));
+ var uInt64ArrayElementType = uInt64Array.SetElementType(typeof(ulong));
+ uInt64ArrayElementType.TypeMapping = uInt64Array.TypeMapping.ElementTypeMapping;
var uInt8 = runtimeEntityType.AddProperty(
"UInt8",
@@ -8599,6 +8703,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
byte (byte v) => v),
clrType: typeof(byte),
jsonValueReaderWriter: JsonByteReaderWriter.Instance));
+ var uInt8ReadOnlyCollectionElementType = uInt8ReadOnlyCollection.SetElementType(typeof(byte));
+ uInt8ReadOnlyCollectionElementType.TypeMapping = uInt8ReadOnlyCollection.TypeMapping.ElementTypeMapping;
var uri = runtimeEntityType.AddProperty(
"Uri",
@@ -8739,7 +8845,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
beforeSaveBehavior: PropertySaveBehavior.Ignore,
afterSaveBehavior: PropertySaveBehavior.Ignore);
__jObject.SetAccessors(
- JObject (InternalEntityEntry entry) => (entry.FlaggedAsStoreGenerated(169) ? entry.ReadStoreGeneratedValue(1) : (entry.FlaggedAsTemporary(169) && entry.ReadShadowValue(2) == null ? entry.ReadTemporaryValue(1) : entry.ReadShadowValue(2))),
+ JObject (InternalEntityEntry entry) => (entry.FlaggedAsStoreGenerated(169) ? entry.ReadStoreGeneratedValue(0) : (entry.FlaggedAsTemporary(169) && entry.ReadShadowValue(2) == null ? entry.ReadTemporaryValue(0) : entry.ReadShadowValue(2))),
JObject (InternalEntityEntry entry) => entry.ReadShadowValue(2),
JObject (InternalEntityEntry entry) => entry.ReadOriginalValue(__jObject, 169),
JObject (InternalEntityEntry entry) => entry.GetCurrentValue(__jObject),
@@ -8749,7 +8855,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
originalValueIndex: 169,
shadowIndex: 2,
relationshipIndex: -1,
- storeGenerationIndex: 1);
+ storeGenerationIndex: 0);
__jObject.TypeMapping = CosmosTypeMapping.Default.Clone(
comparer: new ValueComparer(
bool (JObject v1, JObject v2) => object.Equals(v1, v2),
@@ -8965,9 +9071,9 @@ public static void CreateAnnotations(RuntimeEntityType runtimeEntityType)
return ((ISnapshot)(new MultiSnapshot(new ISnapshot[] { liftedArg, liftedArg0, liftedArg1, liftedArg2, liftedArg3, ((ISnapshot)(new Snapshot, Uri, Uri, string, JObject>((source.GetCurrentValue(stringToUriConverterProperty) == null ? null : ((ValueComparer)(((IProperty)stringToUriConverterProperty).GetValueComparer())).Snapshot(source.GetCurrentValue(stringToUriConverterProperty))), ((ValueComparer)(((IProperty)timeOnly).GetValueComparer())).Snapshot(source.GetCurrentValue(timeOnly)), ((ValueComparer)(((IProperty)timeOnlyToStringConverterProperty).GetValueComparer())).Snapshot(source.GetCurrentValue(timeOnlyToStringConverterProperty)), ((ValueComparer)(((IProperty)timeOnlyToTicksConverterProperty).GetValueComparer())).Snapshot(source.GetCurrentValue(timeOnlyToTicksConverterProperty)), ((ValueComparer)(((IProperty)timeSpan).GetValueComparer())).Snapshot(source.GetCurrentValue(timeSpan)), ((ValueComparer)(((IProperty)timeSpanToStringConverterProperty).GetValueComparer())).Snapshot(source.GetCurrentValue(timeSpanToStringConverterProperty)), ((ValueComparer)(((IProperty)timeSpanToTicksConverterProperty).GetValueComparer())).Snapshot(source.GetCurrentValue(timeSpanToTicksConverterProperty)), ((ValueComparer)(((IProperty)uInt16).GetValueComparer())).Snapshot(source.GetCurrentValue(uInt16)), (((IEnumerable)(source.GetCurrentValue(uInt16Array))) == null ? null : ((ushort[])(((ValueComparer>)(((IProperty)uInt16Array).GetValueComparer())).Snapshot(((IEnumerable)(source.GetCurrentValue(uInt16Array))))))), ((ValueComparer)(((IProperty)uInt32).GetValueComparer())).Snapshot(source.GetCurrentValue(uInt32)), (((IEnumerable)(source.GetCurrentValue(uInt32Array))) == null ? null : ((uint[])(((ValueComparer>)(((IProperty)uInt32Array).GetValueComparer())).Snapshot(((IEnumerable)(source.GetCurrentValue(uInt32Array))))))), ((ValueComparer)(((IProperty)uInt64).GetValueComparer())).Snapshot(source.GetCurrentValue(uInt64)), (((IEnumerable)(source.GetCurrentValue(uInt64Array))) == null ? null : ((ulong[])(((ValueComparer>)(((IProperty)uInt64Array).GetValueComparer())).Snapshot(((IEnumerable)(source.GetCurrentValue(uInt64Array))))))), ((ValueComparer)(((IProperty)uInt8).GetValueComparer())).Snapshot(source.GetCurrentValue(uInt8)), (source.GetCurrentValue(uInt8Array) == null ? null : ((ValueComparer)(((IProperty)uInt8Array).GetValueComparer())).Snapshot(source.GetCurrentValue(uInt8Array))), (((IEnumerable)(source.GetCurrentValue>(uInt8ReadOnlyCollection))) == null ? null : ((IReadOnlyCollection)(((ValueComparer>)(((IProperty)uInt8ReadOnlyCollection).GetValueComparer())).Snapshot(((IEnumerable)(source.GetCurrentValue>(uInt8ReadOnlyCollection))))))), (source.GetCurrentValue(uri) == null ? null : ((ValueComparer)(((IProperty)uri).GetValueComparer())).Snapshot(source.GetCurrentValue(uri))), (source.GetCurrentValue(uriToStringConverterProperty) == null ? null : ((ValueComparer)(((IProperty)uriToStringConverterProperty).GetValueComparer())).Snapshot(source.GetCurrentValue(uriToStringConverterProperty))), (source.GetCurrentValue(__id) == null ? null : ((ValueComparer)(((IProperty)__id).GetValueComparer())).Snapshot(source.GetCurrentValue(__id))), (source.GetCurrentValue(__jObject) == null ? null : ((ValueComparer)(((IProperty)__jObject).GetValueComparer())).Snapshot(source.GetCurrentValue(__jObject)))))) })));
});
runtimeEntityType.SetStoreGeneratedValuesFactory(
- ISnapshot () => ((ISnapshot)(new Snapshot(((ValueComparer)(((IProperty)id).GetValueComparer())).Snapshot(default(CompiledModelTestBase.ManyTypesId)), (default(JObject) == null ? null : ((ValueComparer)(((IProperty)__jObject).GetValueComparer())).Snapshot(default(JObject)))))));
+ ISnapshot () => ((ISnapshot)(new Snapshot((default(JObject) == null ? null : ((ValueComparer)(((IProperty)__jObject).GetValueComparer())).Snapshot(default(JObject)))))));
runtimeEntityType.SetTemporaryValuesFactory(
- ISnapshot (InternalEntityEntry source) => ((ISnapshot)(new Snapshot(default(CompiledModelTestBase.ManyTypesId), default(JObject)))));
+ ISnapshot (InternalEntityEntry source) => ((ISnapshot)(new Snapshot(default(JObject)))));
runtimeEntityType.SetShadowValuesFactory(
ISnapshot (IDictionary source) => ((ISnapshot)(new Snapshot((source.ContainsKey("$type") ? ((string)(source["$type"])) : null), (source.ContainsKey("__id") ? ((string)(source["__id"])) : null), (source.ContainsKey("__jObject") ? ((JObject)(source["__jObject"])) : null)))));
runtimeEntityType.SetEmptyShadowValuesFactory(
@@ -8985,7 +9091,7 @@ public static void CreateAnnotations(RuntimeEntityType runtimeEntityType)
originalValueCount: 170,
shadowCount: 3,
relationshipCount: 1,
- storeGeneratedCount: 2);
+ storeGeneratedCount: 1);
Customize(runtimeEntityType);
}
diff --git a/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/BigModel/OwnedType0EntityType.cs b/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/BigModel/OwnedType0EntityType.cs
index bbb9a7fee83..32042329ca1 100644
--- a/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/BigModel/OwnedType0EntityType.cs
+++ b/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/BigModel/OwnedType0EntityType.cs
@@ -291,6 +291,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
string (string v) => v),
clrType: typeof(string),
jsonValueReaderWriter: JsonStringReaderWriter.Instance));
+ var refTypeEnumerableElementType = refTypeEnumerable.SetElementType(typeof(string));
+ refTypeEnumerableElementType.TypeMapping = refTypeEnumerable.TypeMapping.ElementTypeMapping;
var refTypeIList = runtimeEntityType.AddProperty(
"RefTypeIList",
@@ -350,6 +352,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
string (string v) => v),
clrType: typeof(string),
jsonValueReaderWriter: JsonStringReaderWriter.Instance));
+ var refTypeIListElementType = refTypeIList.SetElementType(typeof(string));
+ refTypeIListElementType.TypeMapping = refTypeIList.TypeMapping.ElementTypeMapping;
var valueTypeArray = runtimeEntityType.AddProperty(
"ValueTypeArray",
@@ -409,6 +413,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
DateTime (DateTime v) => v),
clrType: typeof(DateTime),
jsonValueReaderWriter: JsonDateTimeReaderWriter.Instance));
+ var valueTypeArrayElementType = valueTypeArray.SetElementType(typeof(DateTime));
+ valueTypeArrayElementType.TypeMapping = valueTypeArray.TypeMapping.ElementTypeMapping;
var valueTypeEnumerable = runtimeEntityType.AddProperty(
"ValueTypeEnumerable",
@@ -468,6 +474,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
byte (byte v) => v),
clrType: typeof(byte),
jsonValueReaderWriter: JsonByteReaderWriter.Instance));
+ var valueTypeEnumerableElementType = valueTypeEnumerable.SetElementType(typeof(byte));
+ valueTypeEnumerableElementType.TypeMapping = valueTypeEnumerable.TypeMapping.ElementTypeMapping;
var valueTypeIList = runtimeEntityType.AddProperty(
"ValueTypeIList",
@@ -527,6 +535,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
byte (byte v) => v),
clrType: typeof(byte),
jsonValueReaderWriter: JsonByteReaderWriter.Instance));
+ var valueTypeIListElementType = valueTypeIList.SetElementType(typeof(byte));
+ valueTypeIListElementType.TypeMapping = valueTypeIList.TypeMapping.ElementTypeMapping;
var valueTypeList = runtimeEntityType.AddProperty(
"ValueTypeList",
@@ -586,6 +596,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
short (short v) => v),
clrType: typeof(short),
jsonValueReaderWriter: JsonInt16ReaderWriter.Instance));
+ var valueTypeListElementType = valueTypeList.SetElementType(typeof(short));
+ valueTypeListElementType.TypeMapping = valueTypeList.TypeMapping.ElementTypeMapping;
var __jObject = runtimeEntityType.AddProperty(
"__jObject",
diff --git a/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/BigModel/OwnedTypeEntityType.cs b/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/BigModel/OwnedTypeEntityType.cs
index 163d430ba70..21b7f3843a8 100644
--- a/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/BigModel/OwnedTypeEntityType.cs
+++ b/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/BigModel/OwnedTypeEntityType.cs
@@ -261,6 +261,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
string (string v) => v),
clrType: typeof(string),
jsonValueReaderWriter: JsonStringReaderWriter.Instance));
+ var refTypeEnumerableElementType = refTypeEnumerable.SetElementType(typeof(string));
+ refTypeEnumerableElementType.TypeMapping = refTypeEnumerable.TypeMapping.ElementTypeMapping;
var refTypeIList = runtimeEntityType.AddProperty(
"RefTypeIList",
@@ -321,6 +323,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
string (string v) => v),
clrType: typeof(string),
jsonValueReaderWriter: JsonStringReaderWriter.Instance));
+ var refTypeIListElementType = refTypeIList.SetElementType(typeof(string));
+ refTypeIListElementType.TypeMapping = refTypeIList.TypeMapping.ElementTypeMapping;
var valueTypeArray = runtimeEntityType.AddProperty(
"ValueTypeArray",
@@ -381,6 +385,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
DateTime (DateTime v) => v),
clrType: typeof(DateTime),
jsonValueReaderWriter: JsonDateTimeReaderWriter.Instance));
+ var valueTypeArrayElementType = valueTypeArray.SetElementType(typeof(DateTime));
+ valueTypeArrayElementType.TypeMapping = valueTypeArray.TypeMapping.ElementTypeMapping;
var valueTypeEnumerable = runtimeEntityType.AddProperty(
"ValueTypeEnumerable",
@@ -441,6 +447,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
byte (byte v) => v),
clrType: typeof(byte),
jsonValueReaderWriter: JsonByteReaderWriter.Instance));
+ var valueTypeEnumerableElementType = valueTypeEnumerable.SetElementType(typeof(byte));
+ valueTypeEnumerableElementType.TypeMapping = valueTypeEnumerable.TypeMapping.ElementTypeMapping;
var valueTypeIList = runtimeEntityType.AddProperty(
"ValueTypeIList",
@@ -501,6 +509,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
byte (byte v) => v),
clrType: typeof(byte),
jsonValueReaderWriter: JsonByteReaderWriter.Instance));
+ var valueTypeIListElementType = valueTypeIList.SetElementType(typeof(byte));
+ valueTypeIListElementType.TypeMapping = valueTypeIList.TypeMapping.ElementTypeMapping;
var valueTypeList = runtimeEntityType.AddProperty(
"ValueTypeList",
@@ -561,6 +571,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
short (short v) => v),
clrType: typeof(short),
jsonValueReaderWriter: JsonInt16ReaderWriter.Instance));
+ var valueTypeListElementType = valueTypeList.SetElementType(typeof(short));
+ valueTypeListElementType.TypeMapping = valueTypeList.TypeMapping.ElementTypeMapping;
var __jObject = runtimeEntityType.AddProperty(
"__jObject",
diff --git a/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/BigModel/PrincipalBaseEntityType.cs b/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/BigModel/PrincipalBaseEntityType.cs
index 5ffd77d0bbf..34fd7e9a645 100644
--- a/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/BigModel/PrincipalBaseEntityType.cs
+++ b/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/BigModel/PrincipalBaseEntityType.cs
@@ -425,6 +425,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
string (string v) => v),
clrType: typeof(string),
jsonValueReaderWriter: JsonStringReaderWriter.Instance));
+ var refTypeEnumerableElementType = refTypeEnumerable.SetElementType(typeof(string));
+ refTypeEnumerableElementType.TypeMapping = refTypeEnumerable.TypeMapping.ElementTypeMapping;
var refTypeIList = runtimeEntityType.AddProperty(
"RefTypeIList",
@@ -484,6 +486,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
string (string v) => v),
clrType: typeof(string),
jsonValueReaderWriter: JsonStringReaderWriter.Instance));
+ var refTypeIListElementType = refTypeIList.SetElementType(typeof(string));
+ refTypeIListElementType.TypeMapping = refTypeIList.TypeMapping.ElementTypeMapping;
var valueTypeArray = runtimeEntityType.AddProperty(
"ValueTypeArray",
@@ -543,6 +547,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
DateTime (DateTime v) => v),
clrType: typeof(DateTime),
jsonValueReaderWriter: JsonDateTimeReaderWriter.Instance));
+ var valueTypeArrayElementType = valueTypeArray.SetElementType(typeof(DateTime));
+ valueTypeArrayElementType.TypeMapping = valueTypeArray.TypeMapping.ElementTypeMapping;
var valueTypeEnumerable = runtimeEntityType.AddProperty(
"ValueTypeEnumerable",
@@ -602,6 +608,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
byte (byte v) => v),
clrType: typeof(byte),
jsonValueReaderWriter: JsonByteReaderWriter.Instance));
+ var valueTypeEnumerableElementType = valueTypeEnumerable.SetElementType(typeof(byte));
+ valueTypeEnumerableElementType.TypeMapping = valueTypeEnumerable.TypeMapping.ElementTypeMapping;
var valueTypeIList = runtimeEntityType.AddProperty(
"ValueTypeIList",
@@ -661,6 +669,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
byte (byte v) => v),
clrType: typeof(byte),
jsonValueReaderWriter: JsonByteReaderWriter.Instance));
+ var valueTypeIListElementType = valueTypeIList.SetElementType(typeof(byte));
+ valueTypeIListElementType.TypeMapping = valueTypeIList.TypeMapping.ElementTypeMapping;
var valueTypeList = runtimeEntityType.AddProperty(
"ValueTypeList",
@@ -720,6 +730,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
short (short v) => v),
clrType: typeof(short),
jsonValueReaderWriter: JsonInt16ReaderWriter.Instance));
+ var valueTypeListElementType = valueTypeList.SetElementType(typeof(short));
+ valueTypeListElementType.TypeMapping = valueTypeList.TypeMapping.ElementTypeMapping;
var __id = runtimeEntityType.AddProperty(
"__id",
diff --git a/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/ComplexTypes/PrincipalBaseEntityType.cs b/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/ComplexTypes/PrincipalBaseEntityType.cs
index 2313b2c5705..a623bbfedd4 100644
--- a/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/ComplexTypes/PrincipalBaseEntityType.cs
+++ b/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/ComplexTypes/PrincipalBaseEntityType.cs
@@ -412,6 +412,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
string (string v) => v),
clrType: typeof(string),
jsonValueReaderWriter: JsonStringReaderWriter.Instance));
+ var refTypeEnumerableElementType = refTypeEnumerable.SetElementType(typeof(string));
+ refTypeEnumerableElementType.TypeMapping = refTypeEnumerable.TypeMapping.ElementTypeMapping;
var refTypeIList = runtimeEntityType.AddProperty(
"RefTypeIList",
@@ -471,6 +473,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
string (string v) => v),
clrType: typeof(string),
jsonValueReaderWriter: JsonStringReaderWriter.Instance));
+ var refTypeIListElementType = refTypeIList.SetElementType(typeof(string));
+ refTypeIListElementType.TypeMapping = refTypeIList.TypeMapping.ElementTypeMapping;
var valueTypeArray = runtimeEntityType.AddProperty(
"ValueTypeArray",
@@ -530,6 +534,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
DateTime (DateTime v) => v),
clrType: typeof(DateTime),
jsonValueReaderWriter: JsonDateTimeReaderWriter.Instance));
+ var valueTypeArrayElementType = valueTypeArray.SetElementType(typeof(DateTime));
+ valueTypeArrayElementType.TypeMapping = valueTypeArray.TypeMapping.ElementTypeMapping;
var valueTypeEnumerable = runtimeEntityType.AddProperty(
"ValueTypeEnumerable",
@@ -589,6 +595,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
byte (byte v) => v),
clrType: typeof(byte),
jsonValueReaderWriter: JsonByteReaderWriter.Instance));
+ var valueTypeEnumerableElementType = valueTypeEnumerable.SetElementType(typeof(byte));
+ valueTypeEnumerableElementType.TypeMapping = valueTypeEnumerable.TypeMapping.ElementTypeMapping;
var valueTypeIList = runtimeEntityType.AddProperty(
"ValueTypeIList",
@@ -648,6 +656,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
byte (byte v) => v),
clrType: typeof(byte),
jsonValueReaderWriter: JsonByteReaderWriter.Instance));
+ var valueTypeIListElementType = valueTypeIList.SetElementType(typeof(byte));
+ valueTypeIListElementType.TypeMapping = valueTypeIList.TypeMapping.ElementTypeMapping;
var valueTypeList = runtimeEntityType.AddProperty(
"ValueTypeList",
@@ -707,6 +717,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
short (short v) => v),
clrType: typeof(short),
jsonValueReaderWriter: JsonInt16ReaderWriter.Instance));
+ var valueTypeListElementType = valueTypeList.SetElementType(typeof(short));
+ valueTypeListElementType.TypeMapping = valueTypeList.TypeMapping.ElementTypeMapping;
var __id = runtimeEntityType.AddProperty(
"__id",
@@ -994,6 +1006,8 @@ public static RuntimeComplexProperty Create(RuntimeEntityType declaringType)
string (string v) => v),
clrType: typeof(string),
jsonValueReaderWriter: JsonStringReaderWriter.Instance));
+ var refTypeEnumerableElementType = refTypeEnumerable.SetElementType(typeof(string));
+ refTypeEnumerableElementType.TypeMapping = refTypeEnumerable.TypeMapping.ElementTypeMapping;
var refTypeIList = complexType.AddProperty(
"RefTypeIList",
@@ -1061,6 +1075,8 @@ public static RuntimeComplexProperty Create(RuntimeEntityType declaringType)
string (string v) => v),
clrType: typeof(string),
jsonValueReaderWriter: JsonStringReaderWriter.Instance));
+ var refTypeIListElementType = refTypeIList.SetElementType(typeof(string));
+ refTypeIListElementType.TypeMapping = refTypeIList.TypeMapping.ElementTypeMapping;
var valueTypeArray = complexType.AddProperty(
"ValueTypeArray",
@@ -1128,6 +1144,8 @@ public static RuntimeComplexProperty Create(RuntimeEntityType declaringType)
DateTime (DateTime v) => v),
clrType: typeof(DateTime),
jsonValueReaderWriter: JsonDateTimeReaderWriter.Instance));
+ var valueTypeArrayElementType = valueTypeArray.SetElementType(typeof(DateTime));
+ valueTypeArrayElementType.TypeMapping = valueTypeArray.TypeMapping.ElementTypeMapping;
var valueTypeEnumerable = complexType.AddProperty(
"ValueTypeEnumerable",
@@ -1195,6 +1213,8 @@ public static RuntimeComplexProperty Create(RuntimeEntityType declaringType)
byte (byte v) => v),
clrType: typeof(byte),
jsonValueReaderWriter: JsonByteReaderWriter.Instance));
+ var valueTypeEnumerableElementType = valueTypeEnumerable.SetElementType(typeof(byte));
+ valueTypeEnumerableElementType.TypeMapping = valueTypeEnumerable.TypeMapping.ElementTypeMapping;
var valueTypeIList = complexType.AddProperty(
"ValueTypeIList",
@@ -1262,6 +1282,8 @@ public static RuntimeComplexProperty Create(RuntimeEntityType declaringType)
byte (byte v) => v),
clrType: typeof(byte),
jsonValueReaderWriter: JsonByteReaderWriter.Instance));
+ var valueTypeIListElementType = valueTypeIList.SetElementType(typeof(byte));
+ valueTypeIListElementType.TypeMapping = valueTypeIList.TypeMapping.ElementTypeMapping;
var valueTypeList = complexType.AddProperty(
"ValueTypeList",
@@ -1329,6 +1351,8 @@ public static RuntimeComplexProperty Create(RuntimeEntityType declaringType)
short (short v) => v),
clrType: typeof(short),
jsonValueReaderWriter: JsonInt16ReaderWriter.Instance));
+ var valueTypeListElementType = valueTypeList.SetElementType(typeof(short));
+ valueTypeListElementType.TypeMapping = valueTypeList.TypeMapping.ElementTypeMapping;
PrincipalComplexProperty.Create(complexType);
complexType.AddAnnotation("go", "brr");
@@ -1797,6 +1821,8 @@ public static RuntimeComplexProperty Create(RuntimeComplexType declaringType)
string (string v) => v),
clrType: typeof(string),
jsonValueReaderWriter: JsonStringReaderWriter.Instance));
+ var refTypeEnumerableElementType = refTypeEnumerable.SetElementType(typeof(string));
+ refTypeEnumerableElementType.TypeMapping = refTypeEnumerable.TypeMapping.ElementTypeMapping;
var refTypeIList = complexType.AddProperty(
"RefTypeIList",
@@ -1866,6 +1892,8 @@ public static RuntimeComplexProperty Create(RuntimeComplexType declaringType)
string (string v) => v),
clrType: typeof(string),
jsonValueReaderWriter: JsonStringReaderWriter.Instance));
+ var refTypeIListElementType = refTypeIList.SetElementType(typeof(string));
+ refTypeIListElementType.TypeMapping = refTypeIList.TypeMapping.ElementTypeMapping;
var valueTypeArray = complexType.AddProperty(
"ValueTypeArray",
@@ -1935,6 +1963,8 @@ public static RuntimeComplexProperty Create(RuntimeComplexType declaringType)
DateTime (DateTime v) => v),
clrType: typeof(DateTime),
jsonValueReaderWriter: JsonDateTimeReaderWriter.Instance));
+ var valueTypeArrayElementType = valueTypeArray.SetElementType(typeof(DateTime));
+ valueTypeArrayElementType.TypeMapping = valueTypeArray.TypeMapping.ElementTypeMapping;
var valueTypeEnumerable = complexType.AddProperty(
"ValueTypeEnumerable",
@@ -2004,6 +2034,8 @@ public static RuntimeComplexProperty Create(RuntimeComplexType declaringType)
byte (byte v) => v),
clrType: typeof(byte),
jsonValueReaderWriter: JsonByteReaderWriter.Instance));
+ var valueTypeEnumerableElementType = valueTypeEnumerable.SetElementType(typeof(byte));
+ valueTypeEnumerableElementType.TypeMapping = valueTypeEnumerable.TypeMapping.ElementTypeMapping;
var valueTypeIList = complexType.AddProperty(
"ValueTypeIList",
@@ -2073,6 +2105,8 @@ public static RuntimeComplexProperty Create(RuntimeComplexType declaringType)
byte (byte v) => v),
clrType: typeof(byte),
jsonValueReaderWriter: JsonByteReaderWriter.Instance));
+ var valueTypeIListElementType = valueTypeIList.SetElementType(typeof(byte));
+ valueTypeIListElementType.TypeMapping = valueTypeIList.TypeMapping.ElementTypeMapping;
var valueTypeList = complexType.AddProperty(
"ValueTypeList",
@@ -2142,6 +2176,8 @@ public static RuntimeComplexProperty Create(RuntimeComplexType declaringType)
short (short v) => v),
clrType: typeof(short),
jsonValueReaderWriter: JsonInt16ReaderWriter.Instance));
+ var valueTypeListElementType = valueTypeList.SetElementType(typeof(short));
+ valueTypeListElementType.TypeMapping = valueTypeList.TypeMapping.ElementTypeMapping;
return complexProperty;
}
diff --git a/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/No_NativeAOT/ManyTypesEntityType.cs b/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/No_NativeAOT/ManyTypesEntityType.cs
index f0619692a37..a2b24d7e357 100644
--- a/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/No_NativeAOT/ManyTypesEntityType.cs
+++ b/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/No_NativeAOT/ManyTypesEntityType.cs
@@ -40,7 +40,6 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(CompiledModelTestBase.ManyTypesId),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("Id", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
- valueGenerated: ValueGenerated.OnAdd,
afterSaveBehavior: PropertySaveBehavior.Throw,
valueConverter: new CompiledModelTestBase.ManyTypesIdConverter());
id.SetSentinelFromProviderValue(0);
@@ -63,18 +62,21 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(bool[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("BoolArray", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var boolArrayElementType = boolArray.SetElementType(typeof(bool));
var boolNestedCollection = runtimeEntityType.AddProperty(
"BoolNestedCollection",
typeof(bool[][]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("BoolNestedCollection", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var boolNestedCollectionElementType = boolNestedCollection.SetElementType(typeof(bool[]));
var boolReadOnlyCollection = runtimeEntityType.AddProperty(
"BoolReadOnlyCollection",
typeof(IReadOnlyCollection),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("BoolReadOnlyCollection", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("_boolReadOnlyCollection", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var boolReadOnlyCollectionElementType = boolReadOnlyCollection.SetElementType(typeof(bool));
var boolToStringConverterProperty = runtimeEntityType.AddProperty(
"BoolToStringConverterProperty",
@@ -156,12 +158,14 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(char[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("CharArray", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var charArrayElementType = charArray.SetElementType(typeof(char));
var charNestedCollection = runtimeEntityType.AddProperty(
"CharNestedCollection",
typeof(char[][]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("CharNestedCollection", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var charNestedCollectionElementType = charNestedCollection.SetElementType(typeof(char[]));
var charToStringConverterProperty = runtimeEntityType.AddProperty(
"CharToStringConverterProperty",
@@ -252,6 +256,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(decimal[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("DecimalArray", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var decimalArrayElementType = decimalArray.SetElementType(typeof(decimal));
var decimalNumberToBytesConverterProperty = runtimeEntityType.AddProperty(
"DecimalNumberToBytesConverterProperty",
@@ -281,6 +286,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(double[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("DoubleArray", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var doubleArrayElementType = doubleArray.SetElementType(typeof(double));
var doubleNumberToBytesConverterProperty = runtimeEntityType.AddProperty(
"DoubleNumberToBytesConverterProperty",
@@ -446,6 +452,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(float[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("FloatArray", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var floatArrayElementType = floatArray.SetElementType(typeof(float));
var guid = runtimeEntityType.AddProperty(
"Guid",
@@ -502,6 +509,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(short[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("Int16Array", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var int16ArrayElementType = int16Array.SetElementType(typeof(short));
var int32 = runtimeEntityType.AddProperty(
"Int32",
@@ -515,18 +523,21 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(int[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("Int32Array", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var int32ArrayElementType = int32Array.SetElementType(typeof(int));
var int32NestedCollection = runtimeEntityType.AddProperty(
"Int32NestedCollection",
typeof(int[][]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("Int32NestedCollection", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var int32NestedCollectionElementType = int32NestedCollection.SetElementType(typeof(int[]));
var int32ReadOnlyCollection = runtimeEntityType.AddProperty(
"Int32ReadOnlyCollection",
typeof(IReadOnlyCollection),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("Int32ReadOnlyCollection", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("_int32ReadOnlyCollection", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var int32ReadOnlyCollectionElementType = int32ReadOnlyCollection.SetElementType(typeof(int));
var int64 = runtimeEntityType.AddProperty(
"Int64",
@@ -540,12 +551,14 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(long[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("Int64Array", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var int64ArrayElementType = int64Array.SetElementType(typeof(long));
var int64NestedCollection = runtimeEntityType.AddProperty(
"Int64NestedCollection",
typeof(IList[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("Int64NestedCollection", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var int64NestedCollectionElementType = int64NestedCollection.SetElementType(typeof(IList));
var int8 = runtimeEntityType.AddProperty(
"Int8",
@@ -559,12 +572,14 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(sbyte[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("Int8Array", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var int8ArrayElementType = int8Array.SetElementType(typeof(sbyte));
var int8NestedCollection = runtimeEntityType.AddProperty(
"Int8NestedCollection",
typeof(sbyte[][][]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("Int8NestedCollection", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var int8NestedCollectionElementType = int8NestedCollection.SetElementType(typeof(sbyte[][]));
var intNumberToBytesConverterProperty = runtimeEntityType.AddProperty(
"IntNumberToBytesConverterProperty",
@@ -602,6 +617,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(bool?[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("NullableBoolArray", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var nullableBoolArrayElementType = nullableBoolArray.SetElementType(typeof(bool?),
+ nullable: true);
var nullableBytes = runtimeEntityType.AddProperty(
"NullableBytes",
@@ -622,6 +639,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(char?[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("NullableCharArray", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var nullableCharArrayElementType = nullableCharArray.SetElementType(typeof(char?),
+ nullable: true);
var nullableDateOnly = runtimeEntityType.AddProperty(
"NullableDateOnly",
@@ -649,6 +668,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(decimal?[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("NullableDecimalArray", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var nullableDecimalArrayElementType = nullableDecimalArray.SetElementType(typeof(decimal?),
+ nullable: true);
var nullableDouble = runtimeEntityType.AddProperty(
"NullableDouble",
@@ -662,6 +683,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(double?[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("NullableDoubleArray", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var nullableDoubleArrayElementType = nullableDoubleArray.SetElementType(typeof(double?),
+ nullable: true);
var nullableEnum16 = runtimeEntityType.AddProperty(
"NullableEnum16",
@@ -787,6 +810,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(float?[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("NullableFloatArray", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var nullableFloatArrayElementType = nullableFloatArray.SetElementType(typeof(float?),
+ nullable: true);
var nullableGuid = runtimeEntityType.AddProperty(
"NullableGuid",
@@ -814,6 +839,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(short?[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("NullableInt16Array", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var nullableInt16ArrayElementType = nullableInt16Array.SetElementType(typeof(short?),
+ nullable: true);
var nullableInt32 = runtimeEntityType.AddProperty(
"NullableInt32",
@@ -827,12 +854,15 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(int?[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("NullableInt32Array", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var nullableInt32ArrayElementType = nullableInt32Array.SetElementType(typeof(int?),
+ nullable: true);
var nullableInt32NestedCollection = runtimeEntityType.AddProperty(
"NullableInt32NestedCollection",
typeof(int?[][]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("NullableInt32NestedCollection", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var nullableInt32NestedCollectionElementType = nullableInt32NestedCollection.SetElementType(typeof(int?[]));
var nullableInt64 = runtimeEntityType.AddProperty(
"NullableInt64",
@@ -846,12 +876,15 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(long?[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("NullableInt64Array", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var nullableInt64ArrayElementType = nullableInt64Array.SetElementType(typeof(long?),
+ nullable: true);
var nullableInt64NestedCollection = runtimeEntityType.AddProperty(
"NullableInt64NestedCollection",
typeof(List),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("NullableInt64NestedCollection", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var nullableInt64NestedCollectionElementType = nullableInt64NestedCollection.SetElementType(typeof(long?[][]));
var nullableInt8 = runtimeEntityType.AddProperty(
"NullableInt8",
@@ -865,6 +898,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(sbyte?[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("NullableInt8Array", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var nullableInt8ArrayElementType = nullableInt8Array.SetElementType(typeof(sbyte?),
+ nullable: true);
var nullablePhysicalAddress = runtimeEntityType.AddProperty(
"NullablePhysicalAddress",
@@ -885,12 +920,15 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(string[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("NullableStringArray", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var nullableStringArrayElementType = nullableStringArray.SetElementType(typeof(string),
+ nullable: true);
var nullableStringNestedCollection = runtimeEntityType.AddProperty(
"NullableStringNestedCollection",
typeof(string[][]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("NullableStringNestedCollection", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var nullableStringNestedCollectionElementType = nullableStringNestedCollection.SetElementType(typeof(string[]));
var nullableTimeOnly = runtimeEntityType.AddProperty(
"NullableTimeOnly",
@@ -918,6 +956,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(ushort?[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("NullableUInt16Array", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var nullableUInt16ArrayElementType = nullableUInt16Array.SetElementType(typeof(ushort?),
+ nullable: true);
var nullableUInt32 = runtimeEntityType.AddProperty(
"NullableUInt32",
@@ -931,6 +971,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(uint?[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("NullableUInt32Array", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var nullableUInt32ArrayElementType = nullableUInt32Array.SetElementType(typeof(uint?),
+ nullable: true);
var nullableUInt64 = runtimeEntityType.AddProperty(
"NullableUInt64",
@@ -944,6 +986,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(ulong?[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("NullableUInt64Array", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var nullableUInt64ArrayElementType = nullableUInt64Array.SetElementType(typeof(ulong?),
+ nullable: true);
var nullableUInt8 = runtimeEntityType.AddProperty(
"NullableUInt8",
@@ -957,6 +1001,8 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(byte?[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("NullableUInt8Array", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var nullableUInt8ArrayElementType = nullableUInt8Array.SetElementType(typeof(byte?),
+ nullable: true);
var nullableUri = runtimeEntityType.AddProperty(
"NullableUri",
@@ -996,18 +1042,21 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(string[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("StringArray", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var stringArrayElementType = stringArray.SetElementType(typeof(string));
var stringNestedCollection = runtimeEntityType.AddProperty(
"StringNestedCollection",
typeof(string[][]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("StringNestedCollection", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var stringNestedCollectionElementType = stringNestedCollection.SetElementType(typeof(string[]));
var stringReadOnlyCollection = runtimeEntityType.AddProperty(
"StringReadOnlyCollection",
typeof(IReadOnlyCollection),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("StringReadOnlyCollection", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("_stringReadOnlyCollection", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var stringReadOnlyCollectionElementType = stringReadOnlyCollection.SetElementType(typeof(string));
var stringToBoolConverterProperty = runtimeEntityType.AddProperty(
"StringToBoolConverterProperty",
@@ -1167,6 +1216,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(ushort[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("UInt16Array", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var uInt16ArrayElementType = uInt16Array.SetElementType(typeof(ushort));
var uInt32 = runtimeEntityType.AddProperty(
"UInt32",
@@ -1180,6 +1230,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(uint[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("UInt32Array", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var uInt32ArrayElementType = uInt32Array.SetElementType(typeof(uint));
var uInt64 = runtimeEntityType.AddProperty(
"UInt64",
@@ -1193,6 +1244,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(ulong[]),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("UInt64Array", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var uInt64ArrayElementType = uInt64Array.SetElementType(typeof(ulong));
var uInt8 = runtimeEntityType.AddProperty(
"UInt8",
@@ -1212,6 +1264,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(IReadOnlyCollection),
propertyInfo: typeof(CompiledModelTestBase.ManyTypes).GetProperty("UInt8ReadOnlyCollection", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.ManyTypes).GetField("_uInt8ReadOnlyCollection", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ var uInt8ReadOnlyCollectionElementType = uInt8ReadOnlyCollection.SetElementType(typeof(byte));
var uri = runtimeEntityType.AddProperty(
"Uri",
diff --git a/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/No_NativeAOT/OwnedType0EntityType.cs b/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/No_NativeAOT/OwnedType0EntityType.cs
index b3f5ad457b0..17909e832f3 100644
--- a/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/No_NativeAOT/OwnedType0EntityType.cs
+++ b/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/No_NativeAOT/OwnedType0EntityType.cs
@@ -68,6 +68,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
propertyInfo: typeof(CompiledModelTestBase.OwnedType).GetProperty("RefTypeEnumerable", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.OwnedType).GetField("_refTypeEnumerable", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
nullable: true);
+ var refTypeEnumerableElementType = refTypeEnumerable.SetElementType(typeof(string));
var refTypeIList = runtimeEntityType.AddProperty(
"RefTypeIList",
@@ -75,6 +76,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
propertyInfo: typeof(CompiledModelTestBase.OwnedType).GetProperty("RefTypeIList", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.OwnedType).GetField("_refTypeIList", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
nullable: true);
+ var refTypeIListElementType = refTypeIList.SetElementType(typeof(string));
var valueTypeArray = runtimeEntityType.AddProperty(
"ValueTypeArray",
@@ -82,6 +84,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
propertyInfo: typeof(CompiledModelTestBase.OwnedType).GetProperty("ValueTypeArray", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.OwnedType).GetField("_valueTypeArray", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
nullable: true);
+ var valueTypeArrayElementType = valueTypeArray.SetElementType(typeof(DateTime));
var valueTypeEnumerable = runtimeEntityType.AddProperty(
"ValueTypeEnumerable",
@@ -89,6 +92,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
propertyInfo: typeof(CompiledModelTestBase.OwnedType).GetProperty("ValueTypeEnumerable", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.OwnedType).GetField("_valueTypeEnumerable", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
nullable: true);
+ var valueTypeEnumerableElementType = valueTypeEnumerable.SetElementType(typeof(byte));
var valueTypeIList = runtimeEntityType.AddProperty(
"ValueTypeIList",
@@ -96,6 +100,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
propertyInfo: typeof(CompiledModelTestBase.OwnedType).GetProperty("ValueTypeIList", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.OwnedType).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
nullable: true);
+ var valueTypeIListElementType = valueTypeIList.SetElementType(typeof(byte));
var valueTypeList = runtimeEntityType.AddProperty(
"ValueTypeList",
@@ -103,6 +108,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
propertyInfo: typeof(CompiledModelTestBase.OwnedType).GetProperty("ValueTypeList", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.OwnedType).GetField("_valueTypeList", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
nullable: true);
+ var valueTypeListElementType = valueTypeList.SetElementType(typeof(short));
var __jObject = runtimeEntityType.AddProperty(
"__jObject",
diff --git a/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/No_NativeAOT/OwnedTypeEntityType.cs b/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/No_NativeAOT/OwnedTypeEntityType.cs
index a06446aa7da..e73531546d6 100644
--- a/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/No_NativeAOT/OwnedTypeEntityType.cs
+++ b/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/No_NativeAOT/OwnedTypeEntityType.cs
@@ -66,6 +66,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
fieldInfo: typeof(CompiledModelTestBase.OwnedType).GetField("_refTypeEnumerable", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
propertyAccessMode: PropertyAccessMode.Field,
nullable: true);
+ var refTypeEnumerableElementType = refTypeEnumerable.SetElementType(typeof(string));
var refTypeIList = runtimeEntityType.AddProperty(
"RefTypeIList",
@@ -74,6 +75,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
fieldInfo: typeof(CompiledModelTestBase.OwnedType).GetField("_refTypeIList", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
propertyAccessMode: PropertyAccessMode.Field,
nullable: true);
+ var refTypeIListElementType = refTypeIList.SetElementType(typeof(string));
var valueTypeArray = runtimeEntityType.AddProperty(
"ValueTypeArray",
@@ -82,6 +84,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
fieldInfo: typeof(CompiledModelTestBase.OwnedType).GetField("_valueTypeArray", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
propertyAccessMode: PropertyAccessMode.Field,
nullable: true);
+ var valueTypeArrayElementType = valueTypeArray.SetElementType(typeof(DateTime));
var valueTypeEnumerable = runtimeEntityType.AddProperty(
"ValueTypeEnumerable",
@@ -90,6 +93,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
fieldInfo: typeof(CompiledModelTestBase.OwnedType).GetField("_valueTypeEnumerable", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
propertyAccessMode: PropertyAccessMode.Field,
nullable: true);
+ var valueTypeEnumerableElementType = valueTypeEnumerable.SetElementType(typeof(byte));
var valueTypeIList = runtimeEntityType.AddProperty(
"ValueTypeIList",
@@ -98,6 +102,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
fieldInfo: typeof(CompiledModelTestBase.OwnedType).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
propertyAccessMode: PropertyAccessMode.Field,
nullable: true);
+ var valueTypeIListElementType = valueTypeIList.SetElementType(typeof(byte));
var valueTypeList = runtimeEntityType.AddProperty(
"ValueTypeList",
@@ -106,6 +111,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
fieldInfo: typeof(CompiledModelTestBase.OwnedType).GetField("_valueTypeList", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
propertyAccessMode: PropertyAccessMode.Field,
nullable: true);
+ var valueTypeListElementType = valueTypeList.SetElementType(typeof(short));
var __jObject = runtimeEntityType.AddProperty(
"__jObject",
diff --git a/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/No_NativeAOT/PrincipalBaseEntityType.cs b/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/No_NativeAOT/PrincipalBaseEntityType.cs
index a685bcc3f86..1f721e9e20e 100644
--- a/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/No_NativeAOT/PrincipalBaseEntityType.cs
+++ b/test/EFCore.Cosmos.FunctionalTests/Scaffolding/Baselines/No_NativeAOT/PrincipalBaseEntityType.cs
@@ -90,6 +90,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
propertyInfo: typeof(CompiledModelTestBase.PrincipalBase).GetProperty("RefTypeEnumerable", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.PrincipalBase).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
nullable: true);
+ var refTypeEnumerableElementType = refTypeEnumerable.SetElementType(typeof(string));
var refTypeIList = runtimeEntityType.AddProperty(
"RefTypeIList",
@@ -97,6 +98,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
propertyInfo: typeof(CompiledModelTestBase.PrincipalBase).GetProperty("RefTypeIList", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.PrincipalBase).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
nullable: true);
+ var refTypeIListElementType = refTypeIList.SetElementType(typeof(string));
var valueTypeArray = runtimeEntityType.AddProperty(
"ValueTypeArray",
@@ -104,6 +106,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
propertyInfo: typeof(CompiledModelTestBase.PrincipalBase).GetProperty("ValueTypeArray", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.PrincipalBase).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
nullable: true);
+ var valueTypeArrayElementType = valueTypeArray.SetElementType(typeof(DateTime));
var valueTypeEnumerable = runtimeEntityType.AddProperty(
"ValueTypeEnumerable",
@@ -111,6 +114,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
propertyInfo: typeof(CompiledModelTestBase.PrincipalBase).GetProperty("ValueTypeEnumerable", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.PrincipalBase).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
nullable: true);
+ var valueTypeEnumerableElementType = valueTypeEnumerable.SetElementType(typeof(byte));
var valueTypeIList = runtimeEntityType.AddProperty(
"ValueTypeIList",
@@ -118,6 +122,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
propertyInfo: typeof(CompiledModelTestBase.PrincipalBase).GetProperty("ValueTypeIList", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.PrincipalBase).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
nullable: true);
+ var valueTypeIListElementType = valueTypeIList.SetElementType(typeof(byte));
var valueTypeList = runtimeEntityType.AddProperty(
"ValueTypeList",
@@ -125,6 +130,7 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
propertyInfo: typeof(CompiledModelTestBase.PrincipalBase).GetProperty("ValueTypeList", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.PrincipalBase).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
nullable: true);
+ var valueTypeListElementType = valueTypeList.SetElementType(typeof(short));
var __id = runtimeEntityType.AddProperty(
"__id",
diff --git a/test/EFCore.Cosmos.FunctionalTests/Scaffolding/CompiledModelCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Scaffolding/CompiledModelCosmosTest.cs
index e38f8fdeb86..e933b382810 100644
--- a/test/EFCore.Cosmos.FunctionalTests/Scaffolding/CompiledModelCosmosTest.cs
+++ b/test/EFCore.Cosmos.FunctionalTests/Scaffolding/CompiledModelCosmosTest.cs
@@ -3,6 +3,8 @@
// ReSharper disable InconsistentNaming
+using System.Net;
+using System.Net.NetworkInformation;
using System.Runtime.CompilerServices;
using Microsoft.EntityFrameworkCore.Cosmos.ValueGeneration.Internal;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
@@ -119,7 +121,7 @@ public virtual Task Basic_cosmos_model()
Assert.Null(list.FieldInfo);
Assert.True(list.IsNullable);
Assert.False(list.IsConcurrencyToken);
- Assert.False(list.IsPrimitiveCollection);
+ Assert.True(list.IsPrimitiveCollection);
Assert.Equal(ValueGenerated.Never, list.ValueGenerated);
Assert.Equal(PropertySaveBehavior.Save, list.GetAfterSaveBehavior());
Assert.Equal(PropertySaveBehavior.Save, list.GetBeforeSaveBehavior());
@@ -232,9 +234,11 @@ protected override void BuildBigModel(ModelBuilder modelBuilder, bool jsonColumn
});
});
+
modelBuilder.Entity(
b =>
{
+ b.Property(e => e.Id).HasConversion().ValueGeneratedNever();
// Cosmos provider cannot map collections of elements with converters. See Issue #34026.
b.Ignore(e => e.GuidArray);
b.Ignore(e => e.DateTimeArray);
@@ -335,6 +339,303 @@ protected override void BuildBigModel(ModelBuilder modelBuilder, bool jsonColumn
});
}
+ protected override async Task UseBigModel(DbContext context, bool jsonColumns)
+ {
+ var principalDerived = new PrincipalDerived>
+ {
+ AlternateId = new Guid(),
+ Dependent = new DependentDerived(1, "one"),
+ Owned = new OwnedType(context)
+ };
+
+ var principalId = context.Model.FindEntityType(typeof(PrincipalBase))!.FindProperty(nameof(PrincipalBase.Id))!;
+ if (principalId.ValueGenerated == ValueGenerated.Never)
+ {
+ principalDerived.Id = 10;
+ }
+
+ context.Add(principalDerived);
+
+ var types = new ManyTypes()
+ {
+ Bool = true,
+ UInt8 = 1,
+ Int16 = 2,
+ Int32 = 3,
+ Int64 = 4,
+ UInt16 = 5,
+ UInt32 = 6,
+ UInt64 = 7,
+ Char = 'a',
+ Float = 8.0f,
+ Double = 9.0,
+ Decimal = 10.0m,
+ String = "11",
+ Guid = Guid.NewGuid(),
+ DateTime = new DateTime(2023, 10, 10, 10, 10, 10),
+ DateOnly = new DateOnly(2023, 10, 10),
+ TimeOnly = new TimeOnly(10, 10),
+ TimeSpan = new TimeSpan(1),
+ Bytes = [1, 2, 3],
+ Uri = new Uri("https://www.example.com"),
+ PhysicalAddress = PhysicalAddress.Parse("00-00-00-00-00-01"),
+ IPAddress = IPAddress.Parse("127.0.0.1"),
+
+ NullableBool = true,
+ NullableUInt8 = 1,
+ NullableInt16 = 2,
+ NullableInt32 = 3,
+ NullableInt64 = 4,
+ NullableUInt16 = 5,
+ NullableUInt32 = 6,
+ NullableUInt64 = 7,
+ NullableChar = 'a',
+ NullableFloat = 8.0f,
+ NullableDouble = 9.0,
+ NullableDecimal = 10.0m,
+ NullableString = "11",
+ NullableGuid = Guid.NewGuid(),
+ NullableDateTime = new DateTime(2023, 10, 10, 10, 10, 10),
+ NullableDateOnly = new DateOnly(2023, 10, 10),
+ NullableTimeOnly = new TimeOnly(10, 10),
+ NullableTimeSpan = new TimeSpan(1),
+ NullableBytes = [1, 2, 3],
+ NullableUri = new Uri("https://www.example.com"),
+
+ BoolArray = [true],
+ Int8Array = [1],
+ Int16Array = [2],
+ Int32Array = [3],
+ Int64Array = [4],
+ UInt8Array = [1],
+ UInt16Array = [5],
+ UInt32Array = [6],
+ UInt64Array = [7],
+ CharArray = ['a'],
+ FloatArray = [8.0f],
+ DoubleArray = [9.0],
+ DecimalArray = [10.0m],
+ StringArray = ["11"],
+ GuidArray = [Guid.NewGuid()],
+ DateTimeArray = [new DateTime(2023, 10, 10, 10, 10, 10)],
+ DateOnlyArray = [new DateOnly(2023, 10, 10)],
+ TimeOnlyArray = [new TimeOnly(10, 10)],
+ TimeSpanArray = [new TimeSpan(1)],
+ BytesArray = [[1, 2, 3]],
+ UriArray = [new Uri("https://www.example.com")],
+ IPAddressArray = [IPAddress.Parse("127.0.0.1")],
+ PhysicalAddressArray = [PhysicalAddress.Parse("00-00-00-00-00-01")],
+
+ NullableBoolArray = [true],
+ NullableInt8Array = [1],
+ NullableInt16Array = [2],
+ NullableInt32Array = [3],
+ NullableInt64Array = [4],
+ NullableUInt8Array = [1],
+ NullableUInt16Array = [5],
+ NullableUInt32Array = [6],
+ NullableUInt64Array = [7],
+ NullableCharArray = ['a'],
+ NullableFloatArray = [8.0f],
+ NullableDoubleArray = [9.0],
+ NullableDecimalArray = [10.0m],
+ NullableStringArray = ["11"],
+ NullableGuidArray = [Guid.NewGuid()],
+ NullableDateTimeArray = [new DateTime(2023, 10, 10, 10, 10, 10)],
+ NullableDateOnlyArray = [new DateOnly(2023, 10, 10)],
+ NullableTimeOnlyArray = [new TimeOnly(10, 10)],
+ NullableTimeSpanArray = [new TimeSpan(1)],
+ NullableBytesArray = [[1, 2, 3]],
+ NullableUriArray = [new Uri("https://www.example.com")],
+ NullableIPAddressArray = [IPAddress.Parse("127.0.0.1")],
+ NullablePhysicalAddressArray = [PhysicalAddress.Parse("00-00-00-00-00-01")],
+
+ BoolReadOnlyCollection = [true],
+ UInt8ReadOnlyCollection = [1],
+ Int32ReadOnlyCollection = [2],
+ StringReadOnlyCollection = ["3"],
+ IPAddressReadOnlyCollection = [IPAddress.Parse("127.0.0.1")],
+
+ Enum8 = Enum8.One,
+ Enum16 = Enum16.One,
+ Enum32 = Enum32.One,
+ Enum64 = Enum64.One,
+ EnumU8 = EnumU8.One,
+ EnumU16 = EnumU16.One,
+ EnumU32 = EnumU32.One,
+ EnumU64 = EnumU64.One,
+
+ Enum8AsString = Enum8.One,
+ Enum16AsString = Enum16.One,
+ Enum32AsString = Enum32.One,
+ Enum64AsString = Enum64.One,
+ EnumU8AsString = EnumU8.One,
+ EnumU16AsString = EnumU16.One,
+ EnumU32AsString = EnumU32.One,
+ EnumU64AsString = EnumU64.One,
+
+ Enum8Collection = [Enum8.One],
+ Enum16Collection = [Enum16.One],
+ Enum32Collection = [Enum32.One],
+ Enum64Collection = [Enum64.One],
+ EnumU8Collection = [EnumU8.One],
+ EnumU16Collection = [EnumU16.One],
+ EnumU32Collection = [EnumU32.One],
+ EnumU64Collection = [EnumU64.One],
+
+ Enum8AsStringCollection = [Enum8.One],
+ Enum16AsStringCollection = [Enum16.One],
+ Enum32AsStringCollection = [Enum32.One],
+ Enum64AsStringCollection = [Enum64.One],
+ EnumU8AsStringCollection = [EnumU8.One],
+ EnumU16AsStringCollection = [EnumU16.One],
+ EnumU32AsStringCollection = [EnumU32.One],
+ EnumU64AsStringCollection = [EnumU64.One],
+
+ NullableEnum8Collection = [Enum8.One],
+ NullableEnum16Collection = [Enum16.One],
+ NullableEnum32Collection = [Enum32.One],
+ NullableEnum64Collection = [Enum64.One],
+ NullableEnumU8Collection = [EnumU8.One],
+ NullableEnumU16Collection = [EnumU16.One],
+ NullableEnumU32Collection = [EnumU32.One],
+ NullableEnumU64Collection = [EnumU64.One],
+
+ NullableEnum8AsStringCollection = [Enum8.One],
+ NullableEnum16AsStringCollection = [Enum16.One],
+ NullableEnum32AsStringCollection = [Enum32.One],
+ NullableEnum64AsStringCollection = [Enum64.One],
+ NullableEnumU8AsStringCollection = [EnumU8.One],
+ NullableEnumU16AsStringCollection = [EnumU16.One],
+ NullableEnumU32AsStringCollection = [EnumU32.One],
+ NullableEnumU64AsStringCollection = [EnumU64.One],
+
+ Enum8Array = [Enum8.One],
+ Enum16Array = [Enum16.One],
+ Enum32Array = [Enum32.One],
+ Enum64Array = [Enum64.One],
+ EnumU8Array = [EnumU8.One],
+ EnumU16Array = [EnumU16.One],
+ EnumU32Array = [EnumU32.One],
+ EnumU64Array = [EnumU64.One],
+
+ Enum8AsStringArray = [Enum8.One],
+ Enum16AsStringArray = [Enum16.One],
+ Enum32AsStringArray = [Enum32.One],
+ Enum64AsStringArray = [Enum64.One],
+ EnumU8AsStringArray = [EnumU8.One],
+ EnumU16AsStringArray = [EnumU16.One],
+ EnumU32AsStringArray = [EnumU32.One],
+ EnumU64AsStringArray = [EnumU64.One],
+
+ NullableEnum8Array = [Enum8.One],
+ NullableEnum16Array = [Enum16.One],
+ NullableEnum32Array = [Enum32.One],
+ NullableEnum64Array = [Enum64.One],
+ NullableEnumU8Array = [EnumU8.One],
+ NullableEnumU16Array = [EnumU16.One],
+ NullableEnumU32Array = [EnumU32.One],
+ NullableEnumU64Array = [EnumU64.One],
+
+ NullableEnum8AsStringArray = [Enum8.One],
+ NullableEnum16AsStringArray = [Enum16.One],
+ NullableEnum32AsStringArray = [Enum32.One],
+ NullableEnum64AsStringArray = [Enum64.One],
+ NullableEnumU8AsStringArray = [EnumU8.One],
+ NullableEnumU16AsStringArray = [EnumU16.One],
+ NullableEnumU32AsStringArray = [EnumU32.One],
+ NullableEnumU64AsStringArray = [EnumU64.One],
+
+ BoolNestedCollection = [[true]],
+ UInt8NestedCollection = [[9]],
+ Int8NestedCollection = [[[9]]],
+ Int32NestedCollection = [[9]],
+ Int64NestedCollection = [[[9l]]],
+ CharNestedCollection = [['a']],
+ StringNestedCollection = [["11"]],
+ GuidNestedCollection = [[[Guid.NewGuid()]]],
+ BytesNestedCollection = [[[1, 2, 3]]],
+ NullableUInt8NestedCollection = [[9]],
+ NullableInt32NestedCollection = [[9]],
+ NullableInt64NestedCollection = [[[9l]]],
+ NullableStringNestedCollection = [["11"]],
+ NullableGuidNestedCollection = [[Guid.NewGuid()]],
+ NullableBytesNestedCollection = [[[1, 2, 3]]],
+ NullablePhysicalAddressNestedCollection = [[[PhysicalAddress.Parse("00-00-00-00-00-01")]]],
+
+ Enum8NestedCollection = [[Enum8.One]],
+ Enum32NestedCollection = [[[Enum32.One]]],
+ EnumU64NestedCollection = [[EnumU64.One]],
+ NullableEnum8NestedCollection = [[Enum8.One]],
+ NullableEnum32NestedCollection = [[[Enum32.One]]],
+ NullableEnumU64NestedCollection = [[EnumU64.One]],
+
+ BoolToStringConverterProperty = true,
+ BoolToTwoValuesConverterProperty = true,
+ BoolToZeroOneConverterProperty = true,
+ BytesToStringConverterProperty = [1, 2, 3],
+ CastingConverterProperty = 1,
+ CharToStringConverterProperty = 'a',
+ DateOnlyToStringConverterProperty = new DateOnly(2023, 10, 10),
+ DateTimeOffsetToBinaryConverterProperty = new DateTimeOffset(2023, 10, 10, 10, 10, 10, TimeSpan.Zero),
+ DateTimeOffsetToBytesConverterProperty = new DateTimeOffset(2023, 10, 10, 10, 10, 10, TimeSpan.Zero),
+ DateTimeOffsetToStringConverterProperty = new DateTimeOffset(2023, 10, 10, 10, 10, 10, TimeSpan.Zero),
+ DateTimeToBinaryConverterProperty = new DateTime(2023, 10, 10, 10, 10, 10),
+ DateTimeToStringConverterProperty = new DateTime(2023, 10, 10, 10, 10, 10),
+ EnumToNumberConverterProperty = Enum32.One,
+ EnumToStringConverterProperty = Enum32.One,
+ GuidToBytesConverterProperty = Guid.NewGuid(),
+ GuidToStringConverterProperty = Guid.NewGuid(),
+ IPAddressToBytesConverterProperty = IPAddress.Parse("127.0.0.1"),
+ IPAddressToStringConverterProperty = IPAddress.Parse("127.0.0.1"),
+ IntNumberToBytesConverterProperty = 1,
+ DecimalNumberToBytesConverterProperty = 1.0m,
+ DoubleNumberToBytesConverterProperty = 1.0,
+ IntNumberToStringConverterProperty = 1,
+ DecimalNumberToStringConverterProperty = 1.0m,
+ DoubleNumberToStringConverterProperty = 1.0,
+ PhysicalAddressToBytesConverterProperty = PhysicalAddress.Parse("00-00-00-00-00-01"),
+ PhysicalAddressToStringConverterProperty = PhysicalAddress.Parse("00-00-00-00-00-01"),
+ StringToBoolConverterProperty = "true",
+ StringToBytesConverterProperty = "1",
+ StringToCharConverterProperty = "a",
+ StringToDateOnlyConverterProperty = new DateOnly(2023, 10, 10).ToString(@"yyyy\-MM\-dd"),
+ StringToDateTimeConverterProperty = new DateTime(2023, 10, 10, 10, 10, 10).ToString(@"yyyy\-MM\-dd HH\:mm\:ss.FFFFFFF"),
+ StringToDateTimeOffsetConverterProperty = new DateTimeOffset(2023, 10, 10, 10, 10, 10, TimeSpan.FromHours(1))
+ .ToString(@"yyyy\-MM\-dd HH\:mm\:ss.FFFFFFFzzz"),
+ StringToEnumConverterProperty = "One",
+ StringToGuidConverterProperty = Guid.NewGuid().ToString(),
+ StringToIntNumberConverterProperty = "1",
+ StringToDecimalNumberConverterProperty = "1.0",
+ StringToDoubleNumberConverterProperty = "1.0",
+ StringToTimeOnlyConverterProperty = new TimeOnly(10, 10).ToString("o"),
+ StringToTimeSpanConverterProperty = new TimeSpan(1).ToString("c"),
+ StringToUriConverterProperty = "https://www.example.com/",
+ TimeOnlyToStringConverterProperty = new TimeOnly(10, 10),
+ TimeOnlyToTicksConverterProperty = new TimeOnly(10, 10),
+ TimeSpanToStringConverterProperty = new TimeSpan(1),
+ TimeSpanToTicksConverterProperty = new TimeSpan(1),
+ UriToStringConverterProperty = new Uri("https://www.example.com/"),
+ NullIntToNullStringConverterProperty = null
+ };
+
+ var manyTypesId = context.Model.FindEntityType(typeof(ManyTypes))!.FindProperty(nameof(ManyTypes.Id))!;
+ if (manyTypesId.ValueGenerated == ValueGenerated.Never)
+ {
+ types.Id = new ManyTypesId(17);
+ }
+
+ context.Add(types);
+
+ await context.SaveChangesAsync();
+
+ var principalDerivedFromStore = await context.Set>>().IgnoreAutoIncludes().SingleAsync();
+ Assert.Equal(principalDerived.AlternateId, principalDerivedFromStore.AlternateId);
+
+ var typesFromStore = await context.Set().OrderBy(m => m.Id).FirstAsync();
+ AssertEqual(types, typesFromStore, jsonColumns);
+ }
+
protected override void BuildComplexTypesModel(ModelBuilder modelBuilder)
{
base.BuildComplexTypesModel(modelBuilder);
diff --git a/test/EFCore.InMemory.FunctionalTests/Scaffolding/Baselines/BigModel/DependentBaseEntityType.cs b/test/EFCore.InMemory.FunctionalTests/Scaffolding/Baselines/BigModel/DependentBaseEntityType.cs
index dc8d863b403..87d40f2982e 100644
--- a/test/EFCore.InMemory.FunctionalTests/Scaffolding/Baselines/BigModel/DependentBaseEntityType.cs
+++ b/test/EFCore.InMemory.FunctionalTests/Scaffolding/Baselines/BigModel/DependentBaseEntityType.cs
@@ -1,10 +1,17 @@
//
using System;
+using System.Collections.Generic;
using System.Reflection;
using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.ChangeTracking;
+using Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
+using Microsoft.EntityFrameworkCore.InMemory.Storage.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Scaffolding;
+using Microsoft.EntityFrameworkCore.Storage;
+using Microsoft.EntityFrameworkCore.Storage.Json;
using Microsoft.EntityFrameworkCore.ValueGeneration;
#pragma warning disable 219, 612, 618
@@ -34,12 +41,68 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
typeof(long),
afterSaveBehavior: PropertySaveBehavior.Throw,
sentinel: 0L);
+ principalId.SetAccessors(
+ long (InternalEntityEntry entry) => (entry.FlaggedAsStoreGenerated(0) ? entry.ReadStoreGeneratedValue(0) : (entry.FlaggedAsTemporary(0) && entry.ReadShadowValue(0) == 0L ? entry.ReadTemporaryValue(0) : entry.ReadShadowValue(0))),
+ long (InternalEntityEntry entry) => entry.ReadShadowValue(0),
+ long (InternalEntityEntry entry) => entry.ReadOriginalValue(principalId, 0),
+ long (InternalEntityEntry entry) => entry.ReadRelationshipSnapshotValue(principalId, 0),
+ object (ValueBuffer valueBuffer) => valueBuffer[0]);
+ principalId.SetPropertyIndexes(
+ index: 0,
+ originalValueIndex: 0,
+ shadowIndex: 0,
+ relationshipIndex: 0,
+ storeGenerationIndex: 0);
+ principalId.TypeMapping = InMemoryTypeMapping.Default.Clone(
+ comparer: new ValueComparer(
+ bool (long v1, long v2) => v1 == v2,
+ int (long v) => ((object)v).GetHashCode(),
+ long (long v) => v),
+ keyComparer: new ValueComparer(
+ bool (long v1, long v2) => v1 == v2,
+ int (long v) => ((object)v).GetHashCode(),
+ long (long v) => v),
+ providerValueComparer: new ValueComparer(
+ bool (long v1, long v2) => v1 == v2,
+ int (long v) => ((object)v).GetHashCode(),
+ long (long v) => v),
+ clrType: typeof(long),
+ jsonValueReaderWriter: JsonInt64ReaderWriter.Instance);
+ principalId.SetCurrentValueComparer(new EntryCurrentValueComparer(principalId));
var principalAlternateId = runtimeEntityType.AddProperty(
"PrincipalAlternateId",
typeof(Guid),
afterSaveBehavior: PropertySaveBehavior.Throw,
sentinel: new Guid("00000000-0000-0000-0000-000000000000"));
+ principalAlternateId.SetAccessors(
+ Guid (InternalEntityEntry entry) => (entry.FlaggedAsStoreGenerated(1) ? entry.ReadStoreGeneratedValue(1) : (entry.FlaggedAsTemporary(1) && entry.ReadShadowValue(1) == new Guid("00000000-0000-0000-0000-000000000000") ? entry.ReadTemporaryValue(1) : entry.ReadShadowValue(1))),
+ Guid (InternalEntityEntry entry) => entry.ReadShadowValue(1),
+ Guid (InternalEntityEntry entry) => entry.ReadOriginalValue(principalAlternateId, 1),
+ Guid (InternalEntityEntry entry) => entry.ReadRelationshipSnapshotValue(principalAlternateId, 1),
+ object (ValueBuffer valueBuffer) => valueBuffer[1]);
+ principalAlternateId.SetPropertyIndexes(
+ index: 1,
+ originalValueIndex: 1,
+ shadowIndex: 1,
+ relationshipIndex: 1,
+ storeGenerationIndex: 1);
+ principalAlternateId.TypeMapping = InMemoryTypeMapping.Default.Clone(
+ comparer: new ValueComparer(
+ bool (Guid v1, Guid v2) => v1 == v2,
+ int (Guid v) => ((object)v).GetHashCode(),
+ Guid (Guid v) => v),
+ keyComparer: new ValueComparer(
+ bool (Guid v1, Guid v2) => v1 == v2,
+ int (Guid v) => ((object)v).GetHashCode(),
+ Guid (Guid v) => v),
+ providerValueComparer: new ValueComparer(
+ bool (Guid v1, Guid v2) => v1 == v2,
+ int (Guid v) => ((object)v).GetHashCode(),
+ Guid (Guid v) => v),
+ clrType: typeof(Guid),
+ jsonValueReaderWriter: JsonGuidReaderWriter.Instance);
+ principalAlternateId.SetCurrentValueComparer(new EntryCurrentValueComparer(principalAlternateId));
var enumDiscriminator = runtimeEntityType.AddProperty(
"EnumDiscriminator",
@@ -47,6 +110,33 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
afterSaveBehavior: PropertySaveBehavior.Throw,
valueGeneratorFactory: new DiscriminatorValueGeneratorFactory().Create,
sentinel: CompiledModelTestBase.Enum1.Default);
+ enumDiscriminator.SetAccessors(
+ CompiledModelTestBase.Enum1 (InternalEntityEntry entry) => entry.ReadShadowValue(2),
+ CompiledModelTestBase.Enum1 (InternalEntityEntry entry) => entry.ReadShadowValue(2),
+ CompiledModelTestBase.Enum1 (InternalEntityEntry entry) => entry.ReadOriginalValue(enumDiscriminator, 2),
+ CompiledModelTestBase.Enum1 (InternalEntityEntry entry) => entry.GetCurrentValue(enumDiscriminator),
+ object (ValueBuffer valueBuffer) => valueBuffer[2]);
+ enumDiscriminator.SetPropertyIndexes(
+ index: 2,
+ originalValueIndex: 2,
+ shadowIndex: 2,
+ relationshipIndex: -1,
+ storeGenerationIndex: -1);
+ enumDiscriminator.TypeMapping = InMemoryTypeMapping.Default.Clone(
+ comparer: new ValueComparer(
+ bool (CompiledModelTestBase.Enum1 v1, CompiledModelTestBase.Enum1 v2) => object.Equals(((object)(v1)), ((object)(v2))),
+ int (CompiledModelTestBase.Enum1 v) => ((object)v).GetHashCode(),
+ CompiledModelTestBase.Enum1 (CompiledModelTestBase.Enum1 v) => v),
+ keyComparer: new ValueComparer(
+ bool (CompiledModelTestBase.Enum1 v1, CompiledModelTestBase.Enum1 v2) => object.Equals(((object)(v1)), ((object)(v2))),
+ int (CompiledModelTestBase.Enum1 v) => ((object)v).GetHashCode(),
+ CompiledModelTestBase.Enum1 (CompiledModelTestBase.Enum1 v) => v),
+ providerValueComparer: new ValueComparer(
+ bool (CompiledModelTestBase.Enum1 v1, CompiledModelTestBase.Enum1 v2) => object.Equals(((object)(v1)), ((object)(v2))),
+ int (CompiledModelTestBase.Enum1 v) => ((object)v).GetHashCode(),
+ CompiledModelTestBase.Enum1 (CompiledModelTestBase.Enum1 v) => v),
+ clrType: typeof(CompiledModelTestBase.Enum1),
+ jsonValueReaderWriter: JsonSignedEnumReaderWriter.Instance);
var id = runtimeEntityType.AddProperty(
"Id",
@@ -54,6 +144,44 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
propertyInfo: typeof(CompiledModelTestBase.DependentBase).GetProperty("Id", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.DependentBase).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
nullable: true);
+ id.SetGetter(
+ byte? (CompiledModelTestBase.DependentBase entity) => DependentBaseUnsafeAccessors.Id(entity),
+ bool (CompiledModelTestBase.DependentBase entity) => !(DependentBaseUnsafeAccessors.Id(entity).HasValue),
+ byte? (CompiledModelTestBase.DependentBase instance) => DependentBaseUnsafeAccessors.Id(instance),
+ bool (CompiledModelTestBase.DependentBase instance) => !(DependentBaseUnsafeAccessors.Id(instance).HasValue));
+ id.SetSetter(
+ (CompiledModelTestBase.DependentBase entity, byte? value) => DependentBaseUnsafeAccessors.Id(entity) = value);
+ id.SetMaterializationSetter(
+ (CompiledModelTestBase.DependentBase entity, byte? value) => DependentBaseUnsafeAccessors.Id(entity) = value);
+ id.SetAccessors(
+ byte? (InternalEntityEntry entry) => DependentBaseUnsafeAccessors.Id(((CompiledModelTestBase.DependentBase)(entry.Entity))),
+ byte? (InternalEntityEntry entry) => DependentBaseUnsafeAccessors.Id(((CompiledModelTestBase.DependentBase)(entry.Entity))),
+ byte? (InternalEntityEntry entry) => entry.ReadOriginalValue(id, 3),
+ byte? (InternalEntityEntry entry) => entry.GetCurrentValue(id),
+ object (ValueBuffer valueBuffer) => valueBuffer[3]);
+ id.SetPropertyIndexes(
+ index: 3,
+ originalValueIndex: 3,
+ shadowIndex: -1,
+ relationshipIndex: -1,
+ storeGenerationIndex: -1);
+ id.TypeMapping = InMemoryTypeMapping.Default.Clone(
+ comparer: new ValueComparer(
+ bool (byte v1, byte v2) => v1 == v2,
+ int (byte v) => ((int)(v)),
+ byte (byte v) => v),
+ keyComparer: new ValueComparer(
+ bool (byte v1, byte v2) => v1 == v2,
+ int (byte v) => ((int)(v)),
+ byte (byte v) => v),
+ providerValueComparer: new ValueComparer(
+ bool (byte v1, byte v2) => v1 == v2,
+ int (byte v) => ((int)(v)),
+ byte (byte v) => v),
+ clrType: typeof(byte),
+ jsonValueReaderWriter: JsonByteReaderWriter.Instance);
+ id.SetComparer(new NullableValueComparer(id.TypeMapping.Comparer));
+ id.SetKeyComparer(new NullableValueComparer(id.TypeMapping.KeyComparer));
var key = runtimeEntityType.AddKey(
new[] { principalId, principalAlternateId });
@@ -90,6 +218,27 @@ public static RuntimeForeignKey CreateForeignKey2(RuntimeEntityType declaringEnt
propertyInfo: typeof(CompiledModelTestBase.DependentBase).GetProperty("Principal", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(CompiledModelTestBase.DependentBase).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));
+ principal.SetGetter(
+ CompiledModelTestBase.PrincipalDerived> (CompiledModelTestBase.DependentBase entity) => DependentBaseUnsafeAccessors.Principal(entity),
+ bool (CompiledModelTestBase.DependentBase entity) => DependentBaseUnsafeAccessors.Principal(entity) == null,
+ CompiledModelTestBase.PrincipalDerived> (CompiledModelTestBase.DependentBase instance) => DependentBaseUnsafeAccessors.Principal(instance),
+ bool (CompiledModelTestBase.DependentBase instance) => DependentBaseUnsafeAccessors.Principal(instance) == null);
+ principal.SetSetter(
+ (CompiledModelTestBase.DependentBase entity, CompiledModelTestBase.PrincipalDerived> value) => DependentBaseUnsafeAccessors.Principal(entity) = value);
+ principal.SetMaterializationSetter(
+ (CompiledModelTestBase.DependentBase entity, CompiledModelTestBase.PrincipalDerived> value) => DependentBaseUnsafeAccessors.Principal(entity) = value);
+ principal.SetAccessors(
+ CompiledModelTestBase.PrincipalDerived> (InternalEntityEntry entry) => DependentBaseUnsafeAccessors.Principal(((CompiledModelTestBase.DependentBase)(entry.Entity))),
+ CompiledModelTestBase.PrincipalDerived> (InternalEntityEntry entry) => DependentBaseUnsafeAccessors.Principal(((CompiledModelTestBase.DependentBase)(entry.Entity))),
+ null,
+ CompiledModelTestBase.PrincipalDerived> (InternalEntityEntry entry) => entry.GetCurrentValue>>(principal),
+ null);
+ principal.SetPropertyIndexes(
+ index: 0,
+ originalValueIndex: -1,
+ shadowIndex: -1,
+ relationshipIndex: 2,
+ storeGenerationIndex: -1);
var dependent = principalEntityType.AddNavigation("Dependent",
runtimeForeignKey,
onDependent: false,
@@ -99,11 +248,68 @@ public static RuntimeForeignKey CreateForeignKey2(RuntimeEntityType declaringEnt
eagerLoaded: true,
lazyLoadingEnabled: false);
+ dependent.SetGetter(
+ CompiledModelTestBase.DependentBase (CompiledModelTestBase.PrincipalDerived> entity) => PrincipalDerivedUnsafeAccessors>.Dependent(entity),
+ bool (CompiledModelTestBase.PrincipalDerived> entity) => PrincipalDerivedUnsafeAccessors