Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest bulk ops redesign #2656

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion samples/AspNetODataSample.Web/AspNetODataSample.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@
</Reference>
<Reference Include="Microsoft.Spatial, Version=7.12.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\sln\packages\Microsoft.Spatial.7.12.2\lib\net45\Microsoft.Spatial.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\sln\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
Expand Down
1 change: 1 addition & 0 deletions src/Microsoft.AspNet.OData.Shared/Common/Error.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ internal static ArgumentNullException PropertyNull()
/// Creates an <see cref="ArgumentException"/> with a default message.
/// </summary>
/// <returns>The logged <see cref="Exception"/>.</returns>
[SuppressMessage("Microsoft.Usage", "CA2208:InstantiateArgumentExceptionsCorrectly")]
internal static ArgumentException PropertyNullOrWhiteSpace()
{
return new ArgumentException(CommonWebApiResources.PropertyNullOrWhiteSpace, "value");
Expand Down
70 changes: 70 additions & 0 deletions src/Microsoft.AspNet.OData.Shared/Common/ODataPathHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//-----------------------------------------------------------------------------
// <copyright file="ODataPathHelper.cs" company=".NET Foundation">
// Copyright (c) .NET Foundation and Contributors. All rights reserved.
// See License.txt in the project root for license information.
// </copyright>
//------------------------------------------------------------------------------

using System.Collections.Generic;
using System.Linq;
using Microsoft.OData.UriParser;

namespace Microsoft.AspNet.OData.Common
{
/// <summary>
/// Helper methods for <see cref="ODataPath"/>.
/// </summary>
internal static class ODataPathHelper
{
/// <summary>
/// Get the keys from a <see cref="KeySegment"/>.
/// </summary>
/// <param name="keySegment">The <see cref="KeySegment"/> to extract the keys.</param>
/// <returns>Dictionary of keys.</returns>
public static Dictionary<string, object> KeySegmentAsDictionary(KeySegment keySegment)
{
if (keySegment == null)
{
throw Error.ArgumentNull(nameof(keySegment));
}

return keySegment.Keys.ToDictionary(d => d.Key, d => d.Value);
}

/// <summary>
/// Get the position of the next <see cref="KeySegment"/> in a list of <see cref="ODataPathSegment"/>.
/// </summary>
/// <param name="pathSegments">List of <see cref="ODataPathSegment"/>.</param>
/// <param name="currentPosition">Current position in the list of <see cref="ODataPathSegment"/>.</param>
/// <returns>Position of the next <see cref="KeySegment"/> if it exists, or -1 otherwise.</returns>
public static int GetNextKeySegmentPosition(IReadOnlyList<ODataPathSegment> pathSegments, int currentPosition)
{
if (pathSegments == null)
{
throw Error.ArgumentNull(nameof(pathSegments));
}

if (currentPosition < 0 || currentPosition >= pathSegments.Count)
{
return -1;
}

if (pathSegments[currentPosition] is KeySegment)
{
currentPosition++;
}

for (int i = currentPosition; i < pathSegments.Count; i++)
{
ODataPathSegment currentSegment = pathSegments[i];

if (currentSegment is KeySegment)
{
return i;
}
}

return -1;
}
}
}
66 changes: 66 additions & 0 deletions src/Microsoft.AspNet.OData.Shared/Common/SRResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions src/Microsoft.AspNet.OData.Shared/Common/SRResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -988,4 +988,22 @@
<data name="ShouldHaveNavigationPropertyInNavigationExpandPath" xml:space="preserve">
<value>A navigation property expand path should have navigation property in the path.</value>
</data>
<data name="ResourcesShouldbePresent" xml:space="preserve">
<value>ResourceSetWrapper should have ResourceWrappers in it</value>
</data>
<data name="ResourceSetWrapperSupported" xml:space="preserve">
<value>Can only add ResourceWrapper to ResourceSetWrapper</value>
</data>
<data name="ChangedObjectTypeMismatch" xml:space="preserve">
<value>Cannot use Changed Object of type '{0}' on an entity of type '{1}'.</value>
</data>
<data name="DataModificationException" xml:space="preserve">
<value>Core.DataModificationException</value>
</data>
<data name="ContentID" xml:space="preserve">
<value>Core.ContentID</value>
</data>
<data name="DeltaLinkNotSupported" xml:space="preserve">
<value>DeltaLinks are not supported</value>
</data>
</root>
119 changes: 119 additions & 0 deletions src/Microsoft.AspNet.OData.Shared/DataModificationExceptionType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
//-----------------------------------------------------------------------------
// <copyright file="MessageType.cs" company=".NET Foundation">
// Copyright (c) .NET Foundation and Contributors. All rights reserved.
// See License.txt in the project root for license information.
// </copyright>
//------------------------------------------------------------------------------

using System;
using Microsoft.AspNet.OData.Builder;

namespace Org.OData.Core.V1
{
/// <summary>
/// Represents a Message Type
/// </summary>
public class MessageType
{
/// <summary>
/// Code of message
/// </summary>
public string Code { get; set; }

/// <summary>
/// Actual message
/// </summary>
public string Message { get; set; }

/// <summary>
/// Severity of message
/// </summary>
public string Severity { get; set; }

/// <summary>
/// Target of message
/// </summary>
public string Target { get; set; }

/// <summary>
/// Details of message
/// </summary>
public string Details { get; set; }
}

/// <summary>
/// Represents an Exception Type
/// </summary>
public abstract class ExceptionType
{
/// <summary>
/// Represents a MessageType
/// </summary>
public MessageType MessageType { get; set; }
}

/// <summary>
/// Represents an Exception for Data modification Operation.
/// </summary>
public class DataModificationExceptionType : ExceptionType
{
/// <summary>
/// Initializes a new instance of the <see cref="DataModificationExceptionType"/> class.
/// </summary>
public DataModificationExceptionType(DataModificationOperationKind failedOperation)
{
this.FailedOperation = failedOperation;
}

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

/// <summary>
/// Represents response code
/// </summary>
public Int16 ResponseCode { get; set; }
}

/// <summary>
/// Enumerates the DataModificationOperation for the operation kind
/// </summary>
public enum DataModificationOperationKind
{
/// <summary>
/// Insert new Instance
/// </summary>
Insert,

/// <summary>
/// Update existing Instance
/// </summary>
Update,

/// <summary>
/// Insert new instance or update it if it already exists
/// </summary>
Upsert,

/// <summary>
/// Delete existing instance
/// </summary>
Delete,

/// <summary>
/// Invoke action or function
/// </summary>
Invoke,

/// <summary>
/// Add link between entities
/// </summary>
Link,

/// <summary>
/// Remove link between entities
/// </summary>
Unlink
}
}
Loading