将MS Access查询转换为LINQ

时间:2018-05-17 14:52:02

标签: vb.net linq access

我在MS Access中有以下查询,我正在尝试将其转换为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;

上述查询中引用的MuniCounty也是一个查询:

    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;

我能够将SQL MuniCounty查询转换为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})

我正在尝试将myMuniCty查询结果与Applications和Property表一起加入以实现结果。但是当我引用myMuniCty时,我没有得到这些字段。

有人可以帮忙吗?

提前致谢

EDIL

0 个答案:

没有答案