I want to join these two lists together with common key being the date but whatever I tried doesn’t work, any suggestions?
Classes:
public class item_mod
{
[JsonProperty(PropertyName = "item.price")]
public string price { get; set; }
[JsonProperty(PropertyName = "item.name")]
public string name { get; set; }
[JsonProperty(PropertyName = "@modify_stamp")]
public string stamp { get; set; }
[JsonProperty(PropertyName = "$trans")]
public string trans { get; set; }
[JsonProperty(PropertyName = "trans.date")]
public string date { get; set; }
}
public class trans_mod
{
[DataMember]
public string refer { get; set; }
[DataMember]
public string date { get; set; }
[DataMember]
public string time { get; set; }
[DataMember]
public string location { get; set; }
[DataMember]
public int points { get; set; }
[DataMember]
public string _total { get; set; }
[DataMember]
public string _discount { get; set; }
[JsonProperty(PropertyName = "$$position")]
public string position { get; set; }
[JsonProperty(PropertyName = "@modify_stamp")]
public string stamp { get; set; }
[JsonProperty(PropertyName = "$trans")]
public string trans { get; set; }
}
Lists: (I grouped them with Date being the key)
var q1 = it.GroupBy(x => x.date)
.Select(g => new
{
Date = g.Key,
Details = g.Select(x => new
{
Name = x.name,
Price = x.price,
Trans = x.trans,
})
.ToList()
})
.ToList();
var q2 = t.GroupBy(x => x.date)
.Select(g => new
{
Date = g.Key,
Details = g.Select(x => new
{
Location = x.location,
Points = x.points,
Pos = x.position,
Time = x.time,
Discount = x._discount,
Totals = x._total,
Trans = x.trans,
Ref = x.refer
})
.ToList()
});
I want to merge these two together in a group join - any suggestions how to?
What I've tried so far:
var query = from trans in q2
join item in q1 on q2 equals q1.Date into gj
select new { Date = q2.Date, Item = gj };
=> doesn't work returns blanks
var mergedList = q1.Union(q2).ToList();
=> also doesn't work.
Any help is appreciated, I'm also noting that I am very new to object oriented programming and I'm just trying to figure out how to do things!