0

I have the following query in MS Access and I'm trying to convert it to LINQ (vb.net)

    Select Case Applications.APPLICATIONSIDNUMBER, Applications.TITLENO, Property.PremIDNumber, Property.Proptype, Property.Streetno, 
    Property.Range, Property.Street, Property.Address2, Property.ZipCode, Property.Subdiv, Property.Unit, Property.Interest, 
    Property.ReissueAD, Property.ReissueCD, Property.ReissueBL, Property.Grantor, Property.PDeedDay, Property.PDeedRday, 
    Property.PriorDBk, Property.PriorIns, Property.PriorInsDate, Property.PriorInsTN, Property.SurveyNo, Property.PerRP, 
    Property.MultiProp, Property.Comments, Property.Display, MuniCounty.Premises, MuniCounty.Village, MuniCounty.TOWN, 
    MuniCounty.CITY, MuniCounty.County, MuniCounty.COUNTYCD, MuniCounty.Zone, Applications.Statecode AS State
    FROM (Applications INNER JOIN Property ON Applications.APPLICATIONSIDNUMBER = Property.APPLICATIONSIDNUMBER) 
    LEFT JOIN MuniCounty On Property.PremIDNumber = MuniCounty.MUNIDNUMBER;

The MuniCounty referenced in the above query is also a query:

    Select MUN.MUNIDNUMBER, MUN.Premcode, MUN.Premises, MUN.COUNTYCD, MUN.Village, MUN.TOWN, MUN.CITY, MUN.ZipCode, 
    County.County, County.State, County.Zone, County.MTRate, County.AddTax, County.MTAZone
    From County INNER Join MUN On County.CountyCd = MUN.COUNTYCD;

I was able to conver the SQL MuniCounty Query into LINQ:

 Dim myMuniCty = (From muns In dc.MUNs
                  Join ctys In dc.Counties On muns.COUNTYCD Equals ctys.CountyCd
                  Select New With {muns.MUNIDNUMBER, muns.Premcode, muns.COUNTYCD, muns.Village, muns.TOWN, muns.CITY, muns.ZipCode,
                  ctys.County, ctys.State, ctys.Zone, ctys.MTRate, ctys.AddTax, ctys.MTAZone})

I'm trying to join the myMuniCty query results with the Applications and Property tables to achieve the results. But when I reference the myMuniCty I don't get the fields.

Can someone please help?

Thanks in advance

Edil

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Edil
  • 13
  • 2
  • It's very hard to read that SQL code as just a single block running on like that. Try formatting so it's easily readable and you'll find more people willing to read it and help. – jmcilhinney May 17 '18 at 15:14
  • Perhaps my [SQL to LINQ Recipe](https://stackoverflow.com/questions/49245160/sql-to-linq-with-multiple-join-count-and-left-join/49245786#49245786) would help (though aimed at C#)? – NetMage May 17 '18 at 22:29
  • What does `Select Case` do in MS Access query? – NetMage May 17 '18 at 22:30

0 Answers0