0

There are several posts where people are asking how to merge generic lists. However, in my case I have two seperate linq statements where I am returning two separate database results .ToList()

var appleList = (from al in db.Apples where al.Id == id select al).ToList();
var bananaList = (from bl in db.Bananas where bl.Id == id select bl).ToList();

I tried merging these list like so:

appleList.Concat(bananaList);

but this causes the following error:

'List' does not contain a definition for 'Concat'

How do I combine these two .ToList()?

Skullomania
  • 2,225
  • 2
  • 29
  • 65

1 Answers1

0

Create a fruit class and derive both apples and bananas from it.

https://www.webopedia.com/TERM/B/base_class.html

James Leshko
  • 173
  • 1
  • 3
  • 16