score:5
apologies for the duplicate closure confusion. this question and marked answer will let you have extension method support for removing from observable collections:
removeall for observablecollections?
it won't give support for the from x in y
syntax, but it will let you do:
var c = new observablecollection<selectableitem>();
c.remove(x => x.isselected);
however, with the check x.pid == p.pid
and the note about your other question... if in fact you want to remove items that are in both lists, this might not be the best option.
the except
extension method will produce an enumerable of items that exclude items that are in the enumerable provided as an argument, in your case the second list. this method doesn't mutate the existing enumerable, like most actions it returns a new one, so you would need to set that into a new observablecollection
.
score:4
you can try this.
var toremove = homeviewmodel.recentpatients.where(x=>x.pid == pid).tolist();
foreach (var item in toremove)
homeviewmodel.recentpatients.remove(item);
Source: stackoverflow.com
Related Query
- Using LINQ to delete an element from a ObservableCollection Source
- how delete more than one record from database using Linq in asp.net mvc
- Delete all records from a database using LINQ to SQL
- creating Linq to sqlite dbml from DbLinq source code
- Finding objects which contains at least one element from subset using RavenDB and LINQ
- How do I return a element using LINQ query from an ObservableCollection?
- Can't add a new record with an integer value into database by using linq from code C#
- How to find child element from Json or class object using Linq
- Using LINQ expression to get previous element from a collection
- How to delete an item from a Dictonary using LINQ in C#
- Get the next to last element from a string split using linq
- Return one Element from List using LINQ
- How to delete a single row from database using linq query?
- Delete last record/element from existing XML document using LINQ
- How to verify row existence and delete it from DataTable using Linq or Select command?
- How add uniqe element from List to ObservableCollection by Linq
- Get descendants from specific XML element using LINQ to XML Query
- How to reinsert data from one table onto itself using LINQ in code migration?
- Filter element from SQL Database table using LINQ
- How to delete objects from array using LINQ
- Construct a list of wpf Hyperlink elements from an XML source file using Linq
- how to use the delete from collection using LINQ Statement
- Delete Old Items from Product List Using LINQ
- Remove Element From String Array Using LINQ Contains Value
- Reading xml file: parsing from element attributes using linq
- How to get element from list A and list B using LINQ
- using LINQ to delete specific rows from DataTable
- c# Linq or code to extract groups from a single list of source data
- how to fetch data from database using linq query for relationship 1:N and N:N (between 3 entity) in asp.net mvc EF code first?
- Updating List using LINQ working when execute from Immediate window, not from code direct
More Query from same tag
- C# FileInfo - additional conditions in this LINQ query
- LINQ query to return highest priced item in each category
- Common query for multiple similar entity types in Entity Framework
- Distinct Using Condition Linq
- Group by in linq for email alert
- Comparing performance of SQL query vs Linq
- C# - finding first enum in IEnumerable and casting to string
- Linq to objects multiple statements vs. single statement
- Sorting XML With LINQ
- Split list at marker elements with LINQ?
- Comparing OffSetDateTime's Date part with Today in EF/Linq with NodaTime
- how to search Year between in Dynamic Linq
- LINQ to Nhibernate (3.0) : GroupBy and Sum in subquery gives NoTImplemented
- IQueryable methods are not resolved for dynamic query variable
- What Data Structure can i use here?
- Linq to sql, unable to separate query
- How to report progress on a long call to .Distinct() in C#
- How to reinsert data from one table onto itself using LINQ in code migration?
- Subsequent from clause vs query continuation
- Search with predicate builder in mvc4
- Implement Protobuf net v2 with entity framework return data
- Linq groupby issue
- Linq query between dates
- EF Core: The multi-part identifier \"m.Added\" could not be bound
- C# Linq Inner Join
- Looking for a better way to get a collection of items by ID
- Linq - where clause on child object
- Compare two List<string> using LINQ in C#
- C# Dynamic Linq Query Multiple OR Logic
- Take unique records from text file using LINQ