private static void AppendTypeCastIfNeeded(StringBuilder builder, IEdmEntitySet entitySet, IEdmType expectedType) { ExceptionUtilities.CheckArgumentNotNull(builder, "builder"); ExceptionUtilities.CheckArgumentNotNull(entitySet, "entitySet"); IEdmEntityType entityDataType = expectedType as IEdmEntityType; if (entityDataType == null) { return; } if (entitySet.EntityType() == entityDataType) { // same types; nothing to add to the context URI return; } if (entityDataType.InheritsFrom(entitySet.EntityType())) { // derived type; add the type cast segment builder.Append("/"); builder.Append(entityDataType.FullName()); return; } ExceptionUtilities.Assert(false, "Expected entity type has to be compatible with the base entity type of the set."); }