Skip to content

Commit

Permalink
Squashing Commits
Browse files Browse the repository at this point in the history
Squashing Commits
Update DeltaOfTStructuralType.cs

test change

Update Microsoft.AspNetCore.OData.Test.csproj

Update Microsoft.Test.E2E.AspNetCore3x.OData.csproj

updates

Update WebStack.versions.settings.targets

Update WebStack.versions.settings.targets

Update GetNugetPackageMetadata.proj

Update WebStack.versions.settings.targets

For testing

update

Update BulkInsertController.cs

Updates

updates

updates

Update NuGet.Config

Update BulkOperationPatchHandlersEF.cs

updates
  • Loading branch information
Sreejithpin committed Oct 28, 2021
1 parent 1c9a45a commit 3414464
Show file tree
Hide file tree
Showing 26 changed files with 615 additions and 142 deletions.
5 changes: 1 addition & 4 deletions sln/.nuget/NuGet.Config
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
</solution>
<packageSources>
<clear />
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
<add key="buildTools" value="https://www.myget.org/F/30de4ee06dd54956a82013fa17a3accb/" />
<add key="externalComponentDependencies" value="https://www.myget.org/F/02a8fd0d231848d2ae32cd901e273000" />
<add key="ODataLibNightly" value="https://www.myget.org/F/odlnightly" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public DataModificationExceptionType(DataModificationOperationKind failedOperati
}

/// <summary>
/// Represents king of <see cref="DataModificationOperationKind"/> type of operation
/// Represents kind of <see cref="DataModificationOperationKind"/> type of operation
/// </summary>
public DataModificationOperationKind FailedOperation { get; }

Expand Down
25 changes: 2 additions & 23 deletions src/Microsoft.AspNet.OData.Shared/DeltaOfTStructuralType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,6 @@ internal IDictionary<string, object> DeltaNestedResources
get { return _deltaNestedResources; }
}

internal IDictionary<string, object> DeltaNestedResources
{
get { return _deltaNestedResources; }
}

/// <inheritdoc/>
public override Type ExpectedClrType
=> typeof(TStructuralType);
Expand All @@ -157,27 +152,11 @@ public IList<string> UpdatableProperties
public IODataInstanceAnnotationContainer TransientInstanceAnnotationContainer { get; set; }

/// <inheritdoc />
public ODataIdContainer ODataIdContainer { get; set; }

/// <inheritdoc />
internal PropertyInfo InstanceAnnotationsPropertyInfo { get { return _instanceAnnotationsPropertyInfo; } }


/// <summary>
/// Gets the enum type of <see cref="EdmDeltaEntityKind"/>.
/// </summary>
public EdmDeltaEntityKind DeltaKind { get; protected set; }

/// <inheritdoc />
public IODataInstanceAnnotationContainer TransientInstanceAnnotationContainer { get; set; }

/// <inheritdoc />
public ODataIdContainer ODataIdContainer { get; set; }
public IODataIdContainer ODataIdContainer { get; set; }

/// <inheritdoc />
internal PropertyInfo InstanceAnnotationsPropertyInfo { get { return _instanceAnnotationsPropertyInfo; } }


/// <inheritdoc/>
public override void Clear()
{
Expand Down Expand Up @@ -522,7 +501,7 @@ public void Patch(TStructuralType original, ODataAPIHandlerFactory apiHandlerFac
}

/// <summary>
/// This applies ODataId parsed Navigation paths, get the value identified by that and copy it on original object
/// This is basically Patch on ODataId. This applies ODataId parsed Navigation paths, get the value identified by that and copy it on original object
/// </summary>
private void ApplyODataId(TStructuralType original, ODataAPIHandlerFactory apiHandlerFactory)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ private void PatchItem(EdmStructuredObject changedObj, EdmStructuredObject origi
/// <summary>
/// This applies ODataId parsed Navigation paths, get the value identified by that and copy it on original object, for typeless entities
/// </summary>
private void ApplyODataId(ODataIdContainer container, EdmStructuredObject original, ODataEdmAPIHandlerFactory apiHandlerFactory)
private void ApplyODataId(IODataIdContainer container, EdmStructuredObject original, ODataEdmAPIHandlerFactory apiHandlerFactory)
{
EdmODataAPIHandler edmApiHandler = apiHandlerFactory.GetHandler(container.ODataIdNavigationPath);

Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.AspNet.OData.Shared/EdmEntityObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public EdmEntityObject(IEdmEntityType edmType, bool isNullable)
/// <summary>
/// Container to hold ODataId
/// </summary>
public ODataIdContainer ODataIdContainer { get; set; }
public IODataIdContainer ODataIdContainer { get; set; }

/// <summary>
/// DeltaKind as Entry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,8 @@ private static ODataPath GetODataPath(string id, ODataDeserializerContext readCo
private static void ApplyODataIDContainer(object resource, ODataResourceWrapper resourceWrapper,
ODataDeserializerContext readContext)
{
//if id null check, add delta case as well c
//Setting Odataid , for POCO classes, as a property in the POCO object itself(if user has OdataIDContainer property),
//for Delta and EdmEntity object setting as an added property ODataIdcontianer in those classes
if (resourceWrapper.ResourceBase?.Id != null)
{
string odataId = resourceWrapper.ResourceBase.Id.OriginalString;
Expand All @@ -578,7 +579,7 @@ private static void ApplyODataIDContainer(object resource, ODataResourceWrapper

if (odataPath != null)
{
ODataIdContainer container = new ODataIdContainer();
IODataIdContainer container = new ODataIdContainer();

NavigationPath navigationPath = new NavigationPath(odataId, odataPath.Segments);
container.ODataIdNavigationPath = navigationPath;
Expand All @@ -593,10 +594,19 @@ private static void ApplyODataIDContainer(object resource, ODataResourceWrapper
}
else
{
PropertyInfo containerPropertyInfo = EdmLibHelpers.GetClrType(odataPath.EdmType, readContext.Model).GetProperties().Where(x => x.PropertyType == typeof(ODataIdContainer)).FirstOrDefault();
PropertyInfo containerPropertyInfo = EdmLibHelpers.GetClrType(odataPath.EdmType, readContext.Model).GetProperties().Where(x => x.PropertyType == typeof(IODataIdContainer)).FirstOrDefault();
if (containerPropertyInfo != null)
{
containerPropertyInfo.SetValue(resource, container);
IODataIdContainer resourceContainer = containerPropertyInfo.GetValue(resource) as IODataIdContainer;
if (resourceContainer != null)
{
resourceContainer.ODataIdNavigationPath = navigationPath;
containerPropertyInfo.SetValue(resource, resourceContainer);
}
else
{
containerPropertyInfo.SetValue(resource, container);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,13 @@ private void WriteDeltaResource(object graph, ODataWriter writer, ODataSerialize
{
writer.WriteStart(resource);
WriteDeltaComplexProperties(selectExpandNode, resourceContext, writer);
WriteDeltaNavigationProperties(selectExpandNode, resourceContext, writer);
//TODO: Need to add support to write Navigation Links, etc. using Delta Writer
//https://github.com/OData/odata.net/issues/155
//CLEANUP: merge delta logic with regular logic; requires common base between ODataWriter and ODataDeltaWriter
//WriteDynamicComplexProperties(resourceContext, writer);
//WriteNavigationLinks(selectExpandNode.SelectedNavigationProperties, resourceContext, writer);
//WriteExpandedNavigationProperties(selectExpandNode.ExpandedNavigationProperties, resourceContext, writer);
//WriteExpandedNavigationProperties(selectExpandNode, resourceContext, writer);

writer.WriteEnd();
}
Expand All @@ -226,6 +227,7 @@ private async Task WriteDeltaResourceAsync(object graph, ODataWriter writer, ODa
{
await writer.WriteStartAsync(resource);
await WriteDeltaComplexPropertiesAsync(selectExpandNode, resourceContext, writer);
await WriteDeltaNavigationPropertiesAsync(selectExpandNode, resourceContext, writer);
//TODO: Need to add support to write Navigation Links, etc. using Delta Writer
//https://github.com/OData/odata.net/issues/155
//CLEANUP: merge delta logic with regular logic; requires common base between ODataWriter and ODataDeltaWriter
Expand Down Expand Up @@ -275,6 +277,48 @@ internal void WriteDeltaComplexProperties(SelectExpandNode selectExpandNode,
}
}

internal void WriteDeltaNavigationProperties(SelectExpandNode selectExpandNode, ResourceContext resourceContext, ODataWriter writer)
{
Contract.Assert(resourceContext != null);
Contract.Assert(writer != null);

IEnumerable<KeyValuePair<IEdmNavigationProperty, Type>> navigationProperties = GetNavigationPropertiesToWrite(selectExpandNode, resourceContext);

foreach (KeyValuePair<IEdmNavigationProperty, Type> navigationProperty in navigationProperties)
{
ODataNestedResourceInfo nestedResourceInfo = new ODataNestedResourceInfo
{
IsCollection = navigationProperty.Key.Type.IsCollection(),
Name = navigationProperty.Key.Name
};

writer.WriteStart(nestedResourceInfo);
WriteDeltaComplexAndExpandedNavigationProperty(navigationProperty.Key, null, resourceContext, writer, navigationProperty.Value);
writer.WriteEnd();
}
}

internal async Task WriteDeltaNavigationPropertiesAsync(SelectExpandNode selectExpandNode, ResourceContext resourceContext, ODataWriter writer)
{
Contract.Assert(resourceContext != null);
Contract.Assert(writer != null);

IEnumerable<KeyValuePair<IEdmNavigationProperty, Type>> navigationProperties = GetNavigationPropertiesToWrite(selectExpandNode, resourceContext);

foreach (KeyValuePair<IEdmNavigationProperty, Type> navigationProperty in navigationProperties)
{
ODataNestedResourceInfo nestedResourceInfo = new ODataNestedResourceInfo
{
IsCollection = navigationProperty.Key.Type.IsCollection(),
Name = navigationProperty.Key.Name
};

await writer.WriteStartAsync(nestedResourceInfo);
await WriteDeltaComplexAndExpandedNavigationPropertyAsync(navigationProperty.Key, null, resourceContext, writer, navigationProperty.Value);
await writer.WriteEndAsync();
}
}

private async Task WriteDeltaComplexPropertiesAsync(SelectExpandNode selectExpandNode,
ResourceContext resourceContext, ODataWriter writer)
{
Expand All @@ -298,7 +342,7 @@ private async Task WriteDeltaComplexPropertiesAsync(SelectExpandNode selectExpan
}

private void WriteDeltaComplexAndExpandedNavigationProperty(IEdmProperty edmProperty, SelectExpandClause selectExpandClause,
ResourceContext resourceContext, ODataWriter writer)
ResourceContext resourceContext, ODataWriter writer, Type type = null)
{
Contract.Assert(edmProperty != null);
Contract.Assert(resourceContext != null);
Expand Down Expand Up @@ -331,6 +375,7 @@ private void WriteDeltaComplexAndExpandedNavigationProperty(IEdmProperty edmProp
{
// create the serializer context for the complex and expanded item.
ODataSerializerContext nestedWriteContext = new ODataSerializerContext(resourceContext, selectExpandClause, edmProperty);
nestedWriteContext.Type = type;

// write object.

Expand All @@ -355,7 +400,7 @@ private void WriteDeltaComplexAndExpandedNavigationProperty(IEdmProperty edmProp
}

private async Task WriteDeltaComplexAndExpandedNavigationPropertyAsync(IEdmProperty edmProperty, SelectExpandClause selectExpandClause,
ResourceContext resourceContext, ODataWriter writer)
ResourceContext resourceContext, ODataWriter writer, Type type = null)
{
Contract.Assert(edmProperty != null);
Contract.Assert(resourceContext != null);
Expand Down Expand Up @@ -388,6 +433,7 @@ await writer.WriteStartAsync(new ODataResourceSet
{
// create the serializer context for the complex and expanded item.
ODataSerializerContext nestedWriteContext = new ODataSerializerContext(resourceContext, selectExpandClause, edmProperty);
nestedWriteContext.Type = type;

// write object.

Expand Down Expand Up @@ -1351,6 +1397,43 @@ private IEnumerable<KeyValuePair<IEdmStructuralProperty, PathSelectItem>> GetPro
}
}

private IEnumerable<KeyValuePair<IEdmNavigationProperty, Type>> GetNavigationPropertiesToWrite(SelectExpandNode selectExpandNode, ResourceContext resourceContext)
{
ISet<IEdmNavigationProperty> navigationProperties = selectExpandNode.SelectedNavigationProperties;

if (navigationProperties != null)
{
IEnumerable<string> changedProperties = null;

if (null != resourceContext.ResourceInstance && resourceContext.ResourceInstance is IDelta deltaObject)
{
changedProperties = deltaObject.GetChangedPropertyNames();
dynamic delta = deltaObject;

foreach (IEdmNavigationProperty navigationProperty in navigationProperties)
{
Object obj = null;
if (changedProperties == null || changedProperties.Contains(navigationProperty.Name) && delta.DeltaNestedResources.TryGetValue(navigationProperty.Name, out obj))
{
yield return new KeyValuePair<IEdmNavigationProperty, Type>(navigationProperty, obj.GetType());
}
}
}
else if(null != resourceContext.EdmObject && resourceContext.EdmObject is IDelta changedObject)
{
changedProperties = changedObject.GetChangedPropertyNames();

foreach (IEdmNavigationProperty navigationProperty in navigationProperties)
{
if (changedProperties == null || changedProperties.Contains(navigationProperty.Name))
{
yield return new KeyValuePair<IEdmNavigationProperty, Type>(navigationProperty, typeof(IEdmChangedObject));
}
}
}
}
}

private void WriteExpandedNavigationProperties(SelectExpandNode selectExpandNode, ResourceContext resourceContext, ODataWriter writer)
{
Contract.Assert(resourceContext != null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ internal bool IsUntyped
get
{ if (_isUntyped == null)
{
_isUntyped = typeof(IEdmObject).IsAssignableFrom(Type);
_isUntyped = typeof(IEdmObject).IsAssignableFrom(Type) || typeof(EdmChangedObjectCollection).IsAssignableFrom(Type);
}

return _isUntyped.Value;
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.AspNet.OData.Shared/IDeltaSetItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ public interface IDeltaSetItem
/// <summary>
/// Container to hold ODataId
/// </summary>
ODataIdContainer ODataIdContainer { get; set; }
IODataIdContainer ODataIdContainer { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,12 @@
<Compile Include="$(MSBuildThisFileDirectory)IDeltaSet.cs" />
<Compile Include="$(MSBuildThisFileDirectory)IDeltaSetItem.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DefaultEdmPatchMethodHandler.cs" />
<Compile Include="$(MSBuildThisFileDirectory)EdmPatchMethodHandler.cs" />
<Compile Include="$(MSBuildThisFileDirectory)EdmODataAPIHandler.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DefaultODataAPIHandler.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ODataEdmAPIHandlerFactory.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ODataAPIHandlerFactory.cs" />
<Compile Include="$(MSBuildThisFileDirectory)IODataAPIHandler.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ODataIdResolver.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PathItem.cs" />
<Compile Include="$(MSBuildThisFileDirectory)NavigationPath.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ODataIdContainer.cs" />
Expand Down
Loading

0 comments on commit 3414464

Please sign in to comment.