I have created string to linq query library for internal company needs. We will use this library for querying over REST mainly, but it could be used in a lot of other different situations.
The gist of it is this, a user can create a query and put it in a url like this:
www.test.com/api/v1/users?query=
$where[#eq(Name,Test)&&#gt(Id,12345)]$orderby[Name,-Id]
but they could also write something like this
www.test.com/api/v1/users?query=
$where[#eq(Name,Test)&&#gt(Id,12345)]$last[]
$last[] returns a single object, while
$orderby[Name,-Id] returns a collection
In the library I have a method that will accept that string and accordingly will produce a collection or a single object, I am just not sure if that method should return a type of Object
or dynamic
.
Which is more suitable, which one's going to be less confusing for other devs?
Also, I'm thinking of releasing this lib as open source, but I don't know if there is a need for something like this to get released.
object
ordynamic
? You could return a choice type or just anIEnumerable<User>
with a flag to indicate if its a single result by-design.Provider
property to call eitherCreateQuery
for collections which returns an IQueryable orExecute
for single objects which just returns anObject
. I don't know if a user is going to request a collection or a single object, since they will combine queries however they want. Since i have only one method which will return either a collection or a single object i was wondering if the return type of that method should be adynamic
or anObject
.