Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove an element from an IGrouping

How do I remove an object directly from an IGrouping IGrouping<DateTime, VMAppointment>?

The only way I know of currently is to generate a new IGrouping without the concering element, but I don't like this way because it causes some trouble within my application.

Any ideas?

like image 288
t4nky Avatar asked Aug 28 '12 16:08

t4nky


People also ask

How to remove a property from an object or element?

The first parameter is an object iteration or array The second parameter is an index or a property name of an object with the delete method, You can remove a property from an object or element from an array. If you are removing an property from object, It trigger the view updates reactively.

How to remove an element from an array in Java?

splice is an inbuilt method in an array, used to remove an element from an array and return a new array with the removed list. the start index is a starting index at which the array index element is deleted. count of elements is the number of elements to be removed from a start index

How to get the sequence of values of an igrouping object?

Notice that to access an IGrouping<TKey,TElement> object's sequence of values, you simply use the IGrouping<TKey,TElement> variable itself. // Get an IGrouping object. IGrouping<System.Reflection.MemberTypes, System.Reflection.MemberInfo> group = typeof(String).GetMembers (). GroupBy (member => member.MemberType).

How to remove an element from an array using splice?

splice is an inbuilt method in an array, used to remove an element from an array and return a new array with the removed list. the start index is a starting index at which the array index element is deleted. count of elements is the number of elements to be removed from a start index So, you can be removed with splice using index and object


1 Answers

No, there's no way to mutate an IGrouping<,>, at least in general - and even if you knew the concrete type, I don't believe any of the implementations exposed by the .NET framework allow the group to be mutated.

Presumably the grouping is the result of some query - so if possible, change the original query to exclude the values you aren't interested in.

like image 90
Jon Skeet Avatar answered Oct 12 '22 10:10

Jon Skeet