As far as I know. if you want to use union to combine two table, you should also make sure the column type is the same.
Besides, you say you faced the error. Please post the details error message and table schema for us to reproduce the issue.
Best regards,
Yijing Sun
ASP.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
Member
65 Points
194 Posts
how to bind in one grid with different grids?
Dec 18, 2019 12:45 PM|progy85|LINK
hello,
I want to use Union for retrieve different data with the same columns names but I can't do this.
My code:
var skupaj = (from p in db.tbl_PotniNalogis
join t in db.tbl_relacijes
on p.ID equals t.IDRelacija
where p.DatumIzdaje >= new DateTime(yearod, monthod, dayod) && p.DatumIzdaje <= new DateTime(yeardo, monthdo, daydo) && p.Idkreiranopodjetje == Convert.ToInt32(Session["ID"])
orderby p.Leto, p.Stevilka
group t by new { p.Stevilka, p.Leto, p.Voznik, p.Vozilo, t.Relacija, t.OpisNamena, p.ZacetnoStanje, p.KoncnoStanje, t.DatumRelacije } into g
select new { OpisKnjizbe = "km domaca", Konto = 41410, STM = "sm", MES_OBDOB = g.Key.DatumRelacije.Value.Month, LETO_OBDOB = g.Key.Leto, DEBET = "", DEBET_VAL = "", KREDIT_VAL = "", POTNIK = g.Key.Voznik, SIF_VAL = "EUR", PROKO = "", POSEL = "pn", VP = "", SIF_PP = "", RACUN = g.Key.Stevilka + "/" + g.Key.Leto, DAT_DOK = "", DAT_DUR = "" }).Union
(from p in db.tbl_PotniNalogis
join t in db.tbl_dnevnice_obracuns
on p.ID equals t.IDDnevnica
where p.DatumIzdaje >= new DateTime(yearod, monthod, dayod) && p.DatumIzdaje <= new DateTime(yeardo, monthdo, daydo) && t.Valuta == "EUR" && p.Idkreiranopodjetje == Convert.ToInt32(Session["ID"]) //t.IDDnevnica == Convert.ToInt32(Session["ID"])
orderby p.Leto, p.Stevilka
group t by new { p.Stevilka, p.Leto, p.Voznik, t.DnevnicaZa, t.DnevnicaOdCas, t.DnevnicaDoCas } into g
select new { OpisKnjizbe = "dnevnice domace", Konto = 41400, STM = "sm", MES_OBDOB = g.Key.DnevnicaDoCas.Value.Month, LETO_OBDOB = g.Key.DnevnicaDoCas.Value.Year, DEBET = "", DEBET_VAL = "", KREDIT_VAL = "", POTNIK = g.Key.Voznik, SIF_VAL = "EUR", PROKO = "", POSEL = "pn", VP = "", SIF_PP = "", RACUN = g.Key.Stevilka + "/" + g.Key.Leto, DAT_DOK = "", DAT_DUR = "" });
What is best way for that?
Regards
Contributor
4040 Points
1568 Posts
Re: how to bind in one grid with different grids?
Dec 19, 2019 09:14 AM|yij sun|LINK
Hi progy85,
As far as I know. if you want to use union to combine two table, you should also make sure the column type is the same.
Besides, you say you faced the error. Please post the details error message and table schema for us to reproduce the issue.
Best regards,
Yijing Sun