I think my question is easy, but I'm a newbie in linq... So I'm having a hard time here
My system calls a service, called serviceTOP, that returns me a list of itemTOP {Id, Name}
.
These ItemsTOP aren't in my system, but the user can choose which itemTOP to import to the system.
The imported ItemsTOP becomes an object Item { Id, IdTOP, Name }
So, when the system calls serviceTOP, before showing them to the user, I must filter the already imported items from the list.
Let's go to code:
IList<ItemsTOP> listTOP = new ServiceTOP().GetItemsTOP();
IList<Items> list = new WCFServiceClient().GetItems();
var filteredListTOP = listTOP.Select( i => i.Id ).Except( i => i.IdTOP );
This kind of works, but it returns a list of strings containing only the id.
I'd like to select both id and name of the TOP.
Change this:
listTOP.Select(i => i.Id )
.Except( i => i.IdTOP );
To this:
listTOP.Select(i => new { ID = i.id, Name = i.Name} )
.Except( i => i.IdTOP );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.