Use OrderBy on projected property

25 views
Skip to first unread message

ryana...@gmail.com

unread,
Mar 22, 2016, 4:06:06 PM3/22/16
to SharpRepository
Hi,

When using "GetAll" method, we can set a selector to project the stored data into an object with different shape like below :


public List<MyProjectedObject> GetPropjectedObjects(IQueryOptions<MyObject> options)
{
return
this.GetAll(
it =>
new MyProjectedObject
{
Id = it.Id.ToString(),
Name = it.Name,
Code = it.Code,
}, options)
.ToList();
}

Is it possible to filter and sort the result by the projected object rather than the stored one ? It seems that SharpRepository only sort/filter on the store objects and that is quite limitating in some situations ..

Thanks !

Riana

Jeff Treuting

unread,
Mar 22, 2016, 4:15:36 PM3/22/16
to ryana...@gmail.com, SharpRepository
There is another parameter which can be passed in for Paging and Sorting. This should give you all the info you need: https://github.com/SharpRepository/SharpRepository/wiki/Paging-and-Sorting

Hope that helps.

________________________________________
From: sharpre...@googlegroups.com <sharpre...@googlegroups.com> on behalf of ryana...@gmail.com <ryana...@gmail.com>
Sent: Tuesday, March 22, 2016 1:06 PM
To: SharpRepository
Subject: [SharpRepository] Use OrderBy on projected property
--
You received this message because you are subscribed to the Google Groups "SharpRepository" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sharpreposito...@googlegroups.com.
To post to this group, send email to sharpre...@googlegroups.com.
Visit this group at https://groups.google.com/group/sharprepository.
To view this discussion on the web visit https://groups.google.com/d/msgid/sharprepository/02e21a79-ff90-427b-867e-4525d049dc74%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ryana...@gmail.com

unread,
Mar 22, 2016, 4:29:58 PM3/22/16
to SharpRepository, ryana...@gmail.com
Hi Jeff and thanks for the answer.

I'm sorry but I can't see an example of a sort on a property of projected object from the link you send.

I have a "stored" object MyObject and its projection named MyProjectedObject.
I would like to sort the result according to one property of MyProjectedObject not one of MyObject.

Hope I'm am more clear, I'm sorry my english is not so good :)
Reply all
Reply to author
Forward
0 new messages