c# 4.0 - how to do a union or "or" in this case? -
i have main table has common information of 2 tables. have 2 tables has particular information of each type. have last table has relation of 2 secondary tables. posible last table has relation 1 or both of secondary tables.
the model is:
- maintable(idmaintable, name...)
- secondary01(idsecondary01, idmaintable, name....)
- secondary02(idsecondary02, idmaintable name....)
- data(iddata, name...)
- datarelationship(iddata, idsecondary01, idsecondary02)
i registers in main table of secondary tables has relation data. have iddata condition.
in sql that:
select * maintable, secondary01, datarelationship maintable.idmaintable = secondary01.idmaintable , secondary01.idsecondary01 = datarelationship.idsecondary01 , datarelationship.iddata = 1234 union select * maintable, secondary02, datarelationship maintable.idmaintable = secondary02.idmaintable , secondary02.idsecondary02 = datarelationship.idsecondary02 , datarelationship.iddata = 1234
how can query extended methods or linq entities?
thanks.
you can use enumerable.union
method.
produces set union of 2 sequences using default equality comparer.
like:
var query = (from t in db.maintable r in db.secondary02 //.....your rest of query select ...) .union (from t in db.maintable r in db.secondary02 //.....your rest of query select ...);
Comments
Post a Comment