using Microsoft.OData.Edm;
using Microsoft.OData.ModelBuilder;
namespace odata_core_vocab_fault;
record Book(string ISBN);
class Program
{
static void Main(string[] args)
{
var builder = new ODataConventionModelBuilder();
var books = builder.EntitySet<Book>("Books");
books
.EntityType
.HasKey(e => e.ISBN);
books
.HasDescription()
.HasDescription("A collection of books.");
var edmModel = builder.GetEdmModel();
var entityset = edmModel.FindDeclaredEntitySet("Books");
var description = edmModel.GetDescriptionAnnotation(entityset);
Console.WriteLine(description);
}
}
Expected result
The console prints "A collection of books."
Actual result
The console prints nothing. Inspecting the result while debugging shows description as null.
The DescriptionConfiguration class returned by extension methods such as
HasDescription<TEntity>(this NavigationSourceConfiguration<TEntity> navigationSource)
returns a record edm expression, while methods in the EDM library such as GetLongDescriptionAnnotation(this IEdmModel model, IEdmVocabularyAnnotatable target) expects it to be IEdmStringConstantExpression. The vocabulary at the OASIS-TC also specifies that the annotation should be a string.Assemblies affected
OData ModelBuilder 1.0.9
Reproduce steps
Create a simple console project.
Paste the following into
Program.cs
Expected result
The console prints "A collection of books."
Actual result
The console prints nothing. Inspecting the result while debugging shows
description
as null.