I have two objects
List<Report>
List<Newsletter>
I need certain properties like
Id
Date
Status
text
from the two lists. Is there a way to merge these list and query it using linq statement to return the specific properties as a separate list? Please help.
Structure of the object is as follows:
Report
{
int id,
datetime reportDate,
enum Status,
string text
};
Newsletter
{
int id,
datetime newsletterDate,
string Status,
string text
};
var items =
reportList.Select(x => new { x.Id, x.Date, x.Status, x.text })
.Concat(
newsList.Select(x => new { x.Id, x.Date, x.Status, x.text }) );
Update, to equalize the Status properties:
var items =
reportList.Select(x => new { x.Id, x.Date, Status = x.Status.ToString(), x.text })
.Concat(
newsList.Select(x => new { x.Id, x.Date, Status, x.text }) );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With