I have a unit of work and a repository using EF 4 and POCOs. Since EF requires an ordered set before it can Skip() and Take(), I added the following unit test (without mocks) j
It is spotting "order by {object}" and panicking; it knows how to order by string
, int
, short
, DateTime
, etc - but object
is a bit too vague.
You're going to need the actual lambda to be typed correctly; the simplest approach would be to make Get
generic, i.e.
.... Get<TIdentity>(
Expression<Func<E, TIdentity>> orderbyLambda, int page, int pageSize)
and then:
orderbyLambda: p => p.ID
should (without you changing the code at the caller) automatically make that a Get<short>(...)
in this case via generic type inference. The other option is to leave it as <E,object>
, but re-write the expression tree at the receiver. More work.