Skip to content

Commit

Permalink
Fix some issues for AllowNagivationSourceNull
Browse files Browse the repository at this point in the history
  • Loading branch information
LianwMS committed Jan 14, 2016
1 parent 79eddec commit 70f8a36
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/Microsoft.OData.Core/ODataContextUriBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ private static void ValidateNavigationSource(ODataContextUrlInfo contextUrlInfo)
// at least requires EdmUnknownEntitySet to be present; otherwise validate its navigation
// path as before.
if (!contextUrlInfo.IsUnknownEntitySet && string.IsNullOrEmpty(contextUrlInfo.NavigationPath) ||
contextUrlInfo.IsUnknownEntitySet && string.IsNullOrEmpty(contextUrlInfo.NavigationSource) && string.IsNullOrEmpty(contextUrlInfo.TypeName))
contextUrlInfo.IsUnknownEntitySet && string.IsNullOrEmpty(contextUrlInfo.NavigationSource) &&
string.IsNullOrEmpty(contextUrlInfo.TypeName))
{
throw new ODataException(Strings.ODataContextUriBuilder_NavigationSourceMissingForEntryAndFeed);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ internal static ODataFeedAndEntrySerializationInfo Validate(ODataFeedAndEntrySer
{
ExceptionUtils.CheckArgumentNotNull(serializationInfo.NavigationSourceName, "serializationInfo.NavigationSourceName");
}

ExceptionUtils.CheckArgumentNotNull(serializationInfo.NavigationSourceEntityTypeName, "serializationInfo.NavigationSourceEntityTypeName");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public override void Process(IODataRequestMessage requestMessage, IODataResponse
ODataWriter resultWriter;

IEdmNavigationSource entitySource = this.QueryContext.OperationResultSource ?? this.QueryContext.Target.NavigationSource;
// IEdmNavigationSource entitySource = this.QueryContext.OperationResultSource;

if (this.QueryContext.Target.TypeKind == EdmTypeKind.Collection)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static ODataEntry ConvertToODataEntry(object element, IEdmNavigationSourc
entry.TypeName = element.GetType().Namespace + "." + typeName;

// TODO: work around for now
if (!(entitySource is IEdmContainedEntitySet) && entitySource != null)
if (entitySource != null && !(entitySource is IEdmContainedEntitySet))
{
Uri entryUri = BuildEntryUri(element, entitySource, targetVersion);
if (element.GetType().BaseType != null && entitySource.EntityType().Name != typeName)
Expand Down Expand Up @@ -416,11 +416,11 @@ public static object ConvertPropertyValue(object propertyValue)
var collectionValue = p.Value as ODataCollectionValue;
if (collectionValue != null && !collectionValue.Items.Cast<object>().Any())
{
targetProperty.SetValue(newInstance, Utility.QuickCreateInstance(targetProperty.PropertyType), new object[] { });
targetProperty.SetValue(newInstance, Utility.QuickCreateInstance(targetProperty.PropertyType), new object[] { });
}
else
{
targetProperty.SetValue(newInstance, ConvertPropertyValue(p.Value), new object[] { });
targetProperty.SetValue(newInstance, ConvertPropertyValue(p.Value), new object[] { });
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ private static void CustomizeEntry(Dictionary<string, string> incomingHeaders, O
/// Writes an OData feed.
/// </summary>
/// <param name="writer">The ODataWriter that will write the feed.</param>
/// <param name="entityType">The type of the entity in the feed.</param>
/// <param name="entries">The items from the data store to write to the feed.</param>
/// <param name="entitySet">The entity set in the model that the feed belongs to.</param>
/// <param name="targetVersion">The OData version this segment is targeting.</param>
Expand Down

0 comments on commit 70f8a36

Please sign in to comment.