Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Sreejithpin committed Mar 3, 2022
1 parent 3792f0c commit 14e5111
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
16 changes: 8 additions & 8 deletions src/Microsoft.AspNet.OData.Shared/EdmChangedObjectCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ internal EdmChangedObjectCollection Patch(EdmODataAPIHandler apiHandler, ODataEd
internal EdmChangedObjectCollection CopyChangedValues(EdmODataAPIHandler apiHandler, ODataEdmAPIHandlerFactory apiHandlerFactory = null)
{
EdmChangedObjectCollection changedObjectCollection = new EdmChangedObjectCollection(_entityType);
IEdmStructuralProperty[] keys = _entityType.Key().ToArray();
string[] keys = _entityType.Key().Select(x=>x.Name).ToArray();

foreach (IEdmChangedObject changedObj in Items)
{
Expand Down Expand Up @@ -199,18 +199,18 @@ internal EdmChangedObjectCollection CopyChangedValues(EdmODataAPIHandler apiHand
return changedObjectCollection;
}

private static IDictionary<string, object> GetKeyValues(IEdmStructuralProperty[] keys, IEdmChangedObject changedObj)
private static IDictionary<string, object> GetKeyValues(string[] keys, IEdmChangedObject changedObj)
{
IDictionary<string, object> keyValues = new Dictionary<string, object>();

foreach (IEdmStructuralProperty key in keys)
foreach (string key in keys)
{
object value;
changedObj.TryGetPropertyValue(key.Name, out value);
changedObj.TryGetPropertyValue(key, out value);

if (value != null)
{
keyValues.Add(key.Name, value);
keyValues.Add(key, value);
}
}

Expand Down Expand Up @@ -323,7 +323,7 @@ private void ApplyProperties(EdmStructuredObject changedObj, EdmStructuredObject
}

private IEdmChangedObject HandleFailedOperation(EdmEntityObject changedObj, DataModificationOperationKind operation, IEdmStructuredObject originalObj,
IEdmStructuralProperty[] keys, string errorMessage, EdmODataAPIHandler apiHandler)
string[] keys, string errorMessage, EdmODataAPIHandler apiHandler)
{
IEdmChangedObject edmChangedObject = null;
DataModificationExceptionType dataModificationExceptionType = new DataModificationExceptionType(operation);
Expand Down Expand Up @@ -368,13 +368,13 @@ private IEdmChangedObject HandleFailedOperation(EdmEntityObject changedObj, Data
}

//This is for ODL to work to set id as empty, because if there are missing keys, id wouldnt be set and we need to set it as empty.
private static void ValidateForDeletedEntityId(IEdmStructuralProperty[] keys, EdmDeltaDeletedEntityObject edmDeletedObject)
private static void ValidateForDeletedEntityId(string[] keys, EdmDeltaDeletedEntityObject edmDeletedObject)
{
bool hasNullKeys = false;
for (int i = 0; i < keys.Length; i++)
{
object value;
if (edmDeletedObject.TryGetPropertyValue(keys[i].Name, out value))
if (edmDeletedObject.TryGetPropertyValue(keys[i], out value))
{
hasNullKeys = true;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class EdmDeltaDeletedEntityObject : EdmEntityObject, IEdmDeltaDeletedEnti
{
private string _id;
private DeltaDeletedEntryReason _reason;
private EdmDeltaType _edmType;
private IEdmNavigationSource _navigationSource;

/// <summary>
Expand Down Expand Up @@ -50,7 +49,7 @@ public EdmDeltaDeletedEntityObject(IEdmEntityTypeReference entityTypeReference)
public EdmDeltaDeletedEntityObject(IEdmEntityType entityType, bool isNullable)
: base(entityType, isNullable)
{
_edmType = new EdmDeltaType(entityType, EdmDeltaEntityKind.DeletedEntry);

}

/// <inheritdoc />
Expand Down
3 changes: 1 addition & 2 deletions src/Microsoft.AspNet.OData.Shared/EdmDeltaDeletedLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class EdmDeltaDeletedLink : EdmEntityObject, IEdmDeltaDeletedLink
private Uri _source;
private Uri _target;
private string _relationship;
private EdmDeltaType _edmType;

/// <summary>
/// Initializes a new instance of the <see cref="EdmDeltaDeletedLink"/> class.
Expand Down Expand Up @@ -49,7 +48,7 @@ public EdmDeltaDeletedLink(IEdmEntityTypeReference entityTypeReference)
public EdmDeltaDeletedLink(IEdmEntityType entityType, bool isNullable)
: base(entityType, isNullable)
{
_edmType = new EdmDeltaType(entityType, EdmDeltaEntityKind.DeletedLinkEntry);

}

/// <inheritdoc />
Expand Down
5 changes: 2 additions & 3 deletions src/Microsoft.AspNet.OData.Shared/EdmDeltaEntityObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ namespace Microsoft.AspNet.OData
/// </summary>
[NonValidatingParameterBinding]
public class EdmDeltaEntityObject : EdmEntityObject, IEdmChangedObject
{
private EdmDeltaType _edmType;
{
private IEdmNavigationSource _navigationSource;

/// <summary>
Expand Down Expand Up @@ -47,7 +46,7 @@ public EdmDeltaEntityObject(IEdmEntityTypeReference entityTypeReference)
public EdmDeltaEntityObject(IEdmEntityType entityType, bool isNullable)
: base(entityType, isNullable)
{
_edmType = new EdmDeltaType(entityType, EdmDeltaEntityKind.Entry);

}

/// <inheritdoc />
Expand Down

0 comments on commit 14e5111

Please sign in to comment.