We have a requirement where we need to sort the entity collection in descending order by date in plugin . Can someone help me how to do that?
Hi,
It is not working because you are passing original EntityConnlection object to output parameter
You need to do as below
var entityCollection = new EntityCollection<TEntity>();
foreach (var item m in list)
{
entityCollection.Add(m);
}
Replace list with responseRoomAllocDetails
Then pass entityCollection to output parameter
var responseRoomAllocDetails = entityCollection.Entities.OrderByDescending(x => x.Attributes["pp_lastlogindatetime"]).Select(x => x);
context.OutputParameters["BusinessEntityCollection"] = entityCollection;
This code is not showing any error , but what i am trying to achieve is still not achievable for me
Hi,
Try below code
var responseRoomAllocDetails=roomAllocDetails.Entities.OrderByDescending(x => x.Attributes["createdon"]).Select(x => x);
the entityCollection in your line of code is probably defined as
EntityCollection entityCollection = new EntityCollection();
if you define your records like
List entities = new List();
you can do this line to add the entities like
entityCollection.Entities.AddRange(entities);
so you just need to sort (with LINQ) the List<Entity> with your criteria.
We want to set the entity collection (this data is coming from fetch xml aggregate query) data to the virtual entity . So for this we need to have entity collection before running this following code , we need to sort this Entity collection order by date descending.
context.OutputParameters["BusinessEntityCollection"] = entityCollection;
And with the help of view it is not possible.
why don't configure the view where the data will be shown to be sorted by the date? you don't need to implement this logic inside a retrievemultiple plugin
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156