c# - Linq to SQl, select same column from multiple tables -


I am trying to develop a linq query that returns the ItemNumber column of all my tables in the database, but now Until I have not been able to do it successfully.

Actually I have a table for every type of hardware component in the computer, and each table has an item called the Hambar column. I need to query all the tables in a bang, and return the item number numbers to a flat list / array. (Basically I want to be able to lower down)

  foreach (various items in the item) {Console.WriteLine (c.ItemNumber); }  

Searching for no trace of the trap, can anyone show me how to do this? My best effort on this is low, but I do not understand enough SQL to complete it.

DETBoxPchardware dc.DataBoxPchardware DC from DCM.DataBoxPCHardwareSpeakers in DC dc.DataBoxPCHardwareSpeakers from HSP to dc.DataBoxPCHardwareProcessors in dc.DataBoxPCHardwareMouses from HPC to dc.DataBoxPCHardwarePowerSupplies in HPS from dc.DataBoxPCHardwareOpticalDrives in HMS to DSCDataBoxPCHardwareMotherboards HMC to dc.DataBoxPCHardwareMonitors from HMO in Dc.DataBoxPCHardwareMemories from Hm.DataBoxPCHardwareKeyboards from HCC from dc.DataBoxPCHardwareVideoCards in SCS dcDataBoxPCSoftwareOperatingSystems New {HC, HH, HKB, HM, HM, HMb, HMS, HOD, HPS, HPC, HSP, HVC , SOS} Select ;

There is a consortium you're describing:

SELECT ItemNumber Tbl1 Number of items from Tbl2 to

in LINQ:

  var itemCounts = (Select from hd.ItemNumber from dc.HHD in HDH). Union (HKK select HKK from HKK, ITMNumber in DC). Union (choose HMM in HMM in HMM.Hmm.ITMNumber) and so on  

Note that using unions is not really very efficient. You are getting the entire data set in the database in a round trip, but the database server has to do a separate query for each union, so if you are planning to do some complexity against a lot of data, then you can reconsider Your database design may be better than


Comments