OData / ModelBuilder

A project to generate Edm (Entity Data Model) from CLR types
19 stars 19 forks source link

Multiple entity sets mapping to one controller? #21

Closed dweeden closed 2 years ago

dweeden commented 3 years ago

Wanting to do something very similar to this but running into the same errors.

https://stackoverflow.com/questions/57616954/how-do-i-bind-multiple-entity-sets-to-one-odata-controller

Is there a way to do this with the current Microsoft.AspNetCore.OData 8.02?

dweeden commented 3 years ago

Specifically I'm trying to register the entity sets like this:

modelBuilder.EntitySet<Object>("Meta");
modelBuilder.EntitySet<Field>("Meta");

And then service them within my MetaController with this method

[EnableQuery]
public IActionResult Get(string name)
{
    if (name == "objects")
    {
        return Ok(_context.Objects);
        }
        else if (name == "fields")
    {
        return Ok(_context.Fields);
    }

    return NotFound();
}
xuzhg commented 2 years ago

it seems you are looking for this: https://github.com/OData/AspNetCoreOData/tree/main/sample/ODataDynamicModel

Let me know if it's no or file new issue. thanks.