2012-05-03 11 views
0

私には国が割り当てられている可能性のある住所を持つ対応があります。私はこれを処理するにはどうすればよいクエリオーバービューのnull値を処理します

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); 

問題がヌルであるかもしれないInvoiceAddressCountry、です。その場合、result.BasicInfo_InvoiceAddressCountryプロパティがnullのままになります。 明確にするために、上記のコードは機能しません。 nullを処理することはできません。あなたの言葉から

答えて

1

私はあなたが参加左使用する必要がありますと仮定することができます

.Left.JoinQueryOver(() => invoiceAddres.Country,() => InvoiceAddressCountry) 
関連する問題