yes, there are a few approaches you can take depending on taste. the easiest way to simplify what you've got would be this:
var branchtoremove = _libraryservice.getlibrary(id);
// .single() will throw an exception unless there is one and only one match.
var consortremove = userconsortia.single(
c => c.branches.any(
b => string.equals(b.libraryid, id, stringcomparison.ordinalignorecase));
// remove the consortia
why not something like this? it looks to me from your code that you want to remove the targeted "removal branch" from all consortiums in you collection.
foreach (userconsortium userconsortium in userconsortia)
userconsortium.branches.removeall(c => string.equals(c.libraryid, id, stringcomparison.ordinalignorecase));
- linq remove item from object array where property equals value
- Remove Item From Object SubList (LINQ)
- Remove item from list using linq
- Remove a specific item from a list using LINQ
- Remove an item from a LINQ collection
- creating Linq to sqlite dbml from DbLinq source code
- How to get the second repeated item from a collection of objects using LINQ to object
- Remove an object from a list based on an attribute of another list with linq
- How to remove an item from ListView using LINQ in C#
- Linq code to get the index of an object in an array from an object within a list
- remove nested values from object in linq
- Remove item from xml list with Linq
- c# Linq or code to extract groups from a single list of source data
- how to get a list of item in object from another table using linq and entity framework in C#?
- Using LINQ to remove elements from a List<T>
- Create a list from two object lists with linq
- Linq code to select one item
- Remove item from list based on condition
- How to get first object out from List<Object> using Linq
- How to remove duplicates from collection using IEqualityComparer, LinQ Distinct
- Create a list of one object type from a list of another using Linq
- Remove instances from a list by using LINQ or Lambda?
- Calculate difference from previous item with LINQ
- Linq select object from list depending on objects attribute
- Remove items from list that intersect on property using Linq
- Using Linq to remove from set where key exists in other set?
- Linq to SQL: How do I stop the auto generated object name from being renamed?
- Linq in selecting item from ListViewItemCollections in c#
- How can I set properties on all items from a linq query with values from another object that is also pulled from a query?
- How do I remove items from generic list, based on multiple conditions and using linq
More Query from same tag
- Improving efficiency with lazy/eager loading using a virtual (foreign key) reference
- Executing LINQ expression
- linq list string like
- LINQ and Grouping from a simple SQL DB relationship
- Compare two datatables to find matching values
- How to order a nested Linq object via orderBy
- LINQ query copytodatatable
- Can I use LINQ without Entity Framework?
- Trying to set property in a LINQ GroupBy Select using a loop
- Get List of Records that do not exist in another list - Linq
- How can I use continue statement in .ForEach() method
- linq query to split a time interval into daily batches with part days at start and end
- C# MongoDB, LINQ unable to match by Id
- How to find average when instances are grouped or categorized on multiple columns?
- LINQ filter query with groubBy
- Linq help using "Contains"
- Joining two lists in linq and return consolidated records
- Efficient way of grouping characters in string c#
- LINQ - groupBy with items in several Group
- how to get property nodes if the properties name is "frames"
- Char array help needed
- Why my ordering by linq does not work
- Merge 2 arrays using LINQ
- ASP.NET ReportViewer and Linq To Sql Questions
- Is it possible to use existing classes as POCOs in Entity Framework
- ASP.NET MVC paging large volumes of data using LINQ
- Linq DataContext best practice
- Parsing an Excel file in C#, the cells seem to get cut off at 255 characters... how do I stop that?
- Cache a Linq Query - is this possible?
- Return 0 if no duplicates found from DistinctBy