Open Jevonius opened 9 years ago
Hi Jevon,
The whole issue of schema is something that I'm looking at right now in the v2 work. v1 is basically using guess-work; I want to make it more explicit, just need to come up with the right syntax.
The secondary issue sounds like a bug; I'll take a look.
Hi,
I've noticed a problem with OrderBy that (based on some brief spelunking) I've narrowed down to ToOrderByDirective. I've put together a quick hack fix, but haven't submitted it as a PR as it's quite, well, hacky. I think the problem boils down to the code not handling/considering a lack of aliases in queries.
Example: Two tables, both called Location in different schemas (let's say Hotel and Client). A query such as
db.Hotel.Location.All().OrderByName()
fails with aSequence contains more than one element
exception. This is because there are no aliases in use, so the code inToOrderByDirective
falls to the finalelse
block, which tries toFindTable
across all the schemas.Hack Fix: Adding an extra
else
block along the lines ofif( _columns.Any( r => ( r.ToString() == item.Reference.ToString() ) ) ) { name = item.Reference.GetAllObjectNamesDotted(); }
does resolve the issue, but I suspect there's a much nicer (and better/correct) way to achieve the same thing.Secondary issue: While trying to identify the issue I tried the alternative syntax of
.OrderBy( db.Hotel.Name )
but get an argument exceptionOrderByColumn form does not accept parameters
- is the documentation for OrderBy out of date, or should this be working?