Home
Options

query - two different tables

Hey!

I want to make join from two different tables (with no connection between them):

Parkinglot (parkingLotID, addressParkingLot, statusParkingLot)

PublicParking (publicParkingID, addressPublicParking, statusParking).

And I want to write a query that returns all the parkings that are available -
based on their status (Parkinglot & PublicParking).

I've read that I need to do full outer join (make one big table) and only then I can write the query.

I need to write the query in linq.

I really need your help about this query and about the full outer join (if it's right)

TNX!

Comments

  • Options
    well if it was plain SQL, you'd just use union:

    create table Parkinglot (parkingLotID int, addressParkingLot int, statusParkingLot int) create table PublicParking (publicParkingID int, addressPublicParking int , statusParking int) select * from Parkinglot union select * from PublicParking

    so we can translate to LINQ:

    PublicParkings.Select(pp => new { ParkingType = "Public", ID = pp.PublicParkingID, Status = pp.StatusParking, Address = pp.AddressPublicParking }) .Union( Parkinglots.Select(pl => new { ParkingType = "Lot", ID = pl.ParkingLotID, Status = pl.StatusParkingLot, Address = pl.AddressParkingLot }) )
  • Options
    wow!! thank you!

    But I need only the parkings that their status == "true".

    How do I do this?
Sign In or Register to comment.