0

私には、国が割り当てられている可能性がある住所を持つ相手がいます。

これをどのように処理しますか:

InvoiceAddress invoiceAddres = null;
Country InvoiceAddressCountry = null;
Counterpart counterpart = null;
CounterpartTabDTO result = null;

// projections for DTO-mapping
var projections = new[]
                      {
                          Projections.Property(() => counterpart.CounterpartId).WithAlias(() => result.InternalID),
                          Projections.Property(() => counterpart.GlobalCounterpartId).WithAlias(() => result.BasicInfo_GlobalCounterpartyID),
                          Projections.Property(() => counterpart.Name).WithAlias(() => result.BasicInfo_Name),
                          Projections.Property(() => counterpart.ShortName).WithAlias(() => result.BasicInfo_ShortName),
                          Projections.Property(() => counterpart.PhoneNumber).WithAlias(() => result.BasicInfo_Telephone),
                          Projections.Property(() => counterpart.Webpage).WithAlias(() => result.BasicInfo_WWW),
                          Projections.Property(() => counterpart.Language).WithAlias(() => result.BasicInfo_Language),
                          Projections.Property(() => counterpart.VAT).WithAlias(() => result.BasicInfo_VAT),
                          Projections.Property(() => counterpart.CompanyRegistrationNumber).WithAlias(() => result.BasicInfo_CompanyRegistationno),
                          Projections.Property(() => invoiceAddres.Name).WithAlias(() => result.BasicInfo_InvoiceAddressContactPerson),
                          Projections.Property(() => invoiceAddres.Street).WithAlias(() => result.BasicInfo_InvoiceAddressAddress),
                          Projections.Property(() => invoiceAddres.PostalCode).WithAlias(() => result.BasicInfo_InvoiceAddressPostalCode),
                          Projections.Property(() => invoiceAddres.City).WithAlias(() => result.BasicInfo_InvoiceAddressCity),
                          Projections.Property(() => invoiceAddres.Area).WithAlias(() => result.BasicInfo_InvoiceAddressArea),
                          Projections.Property(() => InvoiceAddressCountry.PrintableName).WithAlias(() => result.BasicInfo_InvoiceAddressCountry),
                          Projections.Property(() => invoiceAddres.Department).WithAlias(() => result.BasicInfo_InvoiceAddressDepartment),
                          Projections.Property(() => invoiceAddres.Fax).WithAlias(() => result.BasicInfo_InvoiceAddressFax),
                          Projections.Property(() => invoiceAddres.MainEmail).WithAlias(() => result.BasicInfo_InvoiceAddressEmail),
                      };
var query = Session.QueryOver(() => counterpart)
    .JoinQueryOver<InvoiceAddress>(x => x.InvoiceAddresses, () => invoiceAddres)
    .Where(x => x.IsDefault)
    .JoinQueryOver<Country>(() => invoiceAddres.Country, () => InvoiceAddressCountry)
    .Select(projections);

問題は、null の可能性がある InvoiceAddressCountry です。その場合、result.BasicInfo_InvoiceAddressCountry プロパティは null のままにしておきたいと思います。明確にするために、上記のコードは機能しません。null を処理できません。

4

1 に答える 1

1

あなたの言葉から、左結合を使用する必要があると推測できます。

.Left.JoinQueryOver(() => invoiceAddres.Country, () => InvoiceAddressCountry)
于 2012-05-03T18:17:31.497 に答える