Closed wbuck closed 2 years ago
Yeah that's right, completely forgot about composite keys. I don't think you can specify that a model has a composite key using attributes (like EF Core). So, when a composite key (or just a regular primary key) has been specified using the fluent API I'm unsure how I can determine which properties have been designated as key(s).
I'm wondering If instead I create a list of properties and create an OrderByQueryOption
with that list and a context object.
Actually, that wont work as they get the properties used a keys via the IEdmEntityType
interface.
I would have thought the following would work:
public class SomeEntity
{
[Key]
public int Identity1 { get; set; }
[Key]
public int Identity2 { get; set; }
public string Name { get; set; }
}
Then this becomes a Where()
.
Everything including the ID properties goes to a hash set.
On second thoughts, maybe it's possible to just grab the keys from the context.
Either way works. If the "how to retrieve the composite keys" piece is wrong then it can be resolved in a separate PR.
Thanks.
Looks like the context will be perfect.
So I have a tentative implementation using the ODataQueryContext
to find the entities/keys I need.
Interested in your thoughts on this approach thus far.
I need to create more tests/test data to get some coverage for entities with multiple keys.
OK, so it's looking good now in terms of ordering by a single, or multiple keys. As a result the code has been simplified which is always a plus.
Thanks @wbuck
Implements support for
$skip
and$top
when a order is not explicitly specified which was discussed here #94.Description: When either
$skip
,$top
, or both are specified without an explicit$orderby
a default order is now created using a suitable property on the model.