Get data from both tables in LINQ -


i trying fetch ip-address column present in both tables, a , b. table a has many ip-adresses , specific ip-address not present in table b. want distinct ip-addresses both tables. means want ip-adresses table a not present in table b, plus ip-adresses table b not present in table a. trying below code giving me ip-adresses not present in table b. please help.

var ips= (from in cs.a  !cs.b.any(f => f.ipaddress == a.ipaddress)     select a.ipaddress).distinct(); 

you can use

 var ips= ((from in cs.a           !cs.b.any(f => f.ipaddress == a.ipaddress)           select a.ipaddress).distinct()).union((from b in cs.b           !cs.a.any(f => f.ipaddress == b.ipaddress)           select b.ipaddress).distinct()); 

Comments