如何解决LINQ中的CS1941错误,C#

huangapple go评论57阅读模式
英文:

How do I resolve CS1941 Error in LINQ, C#

问题

我尝试了这个查询,但是它给我返回了CS1941错误

错误图片:
![错误图片][1]

    ReportList = from hb in (new XPQuery<HallBanquet>(das.UOW))
                         join hbi in (new XPQuery<HallBanquetItem>(das.UOW)) on hb.DocId equals hbi.HallBanquet
                         join cus in (new XPQuery<Customer>(das.UOW)) on hb.Customer equals cus.MastId
                         select new
                         {
                             hb.DocId,
                             hb.Site,
                             hb.DocNo,
                             hb.RefNo,
                             hb.DocDt,
                             hb.Customer, 
                             hb.NoOfPax, 
                             hb.PartyDate, 
                             hb.FromTime, 
                             hb.ToTime, 
                             hb.MainMenu, 
                             hb.OfferPackage,
                             hb.Currency, 
                             hb.CurRate, 
                             hb.LPONo, 
                             hb.LPODate, 
                             hb.ExpectedDeliveryDt, 
                             hb.RoundOff, 
                             hb.SubTotal,
                             hb.NetAmount, 
                             hb.Remarks, 
                             hbi.SeqNo, 
                             hbi.HallBanquet,
                             hbi.ItemType, 
                             hbi.Code, 
                             Desc = hbi.Description,
                             hbi.Item, 
                             hbi.Pkg, 
                             hbi.Unit, 
                             hbi.Qty, 
                             hbi.Price,
                             hbi.Cost, 
                             hbi.DiscountPer, 
                             hbi.DiscountAmt, 
                             hbi.Amount, 
                             hbi.TotalAmt, 
                             hbi.IsInclussiveTax, 
                             hbi.TaxCd,
                             hbi.TaxPer, 
                             hbi.TaxAmt, 
                             hbi.GlCode, 
                             cus.Description
                         };

错误出现在第二行的`join`语句。

  [1]: https://i.stack.imgur.com/2cyEV.png

1. HallBanquet 类:

    ```csharp
    public class HallBanquet : Epimonos.BizObjects.Core.XPDocumentObject
    {
         // 类的定义,请保留原始代码
    }
    ```

2. HallBanquetItem 类(子表):

    ```csharp
    public class HallBanquetItem : XPDocumentDet
    {
        // 类的定义,请保留原始代码
    }
    ```

3. Customer 表:

    ```csharp
    public class Customer : Epimonos.BizObjects.Core.XPMasterObject
    {
        // 类的定义,请保留原始代码
    }
    ```
英文:

I am trying this query but it gives me CS1941 Error.

Image of error:
如何解决LINQ中的CS1941错误,C#

ReportList = from hb in (new XPQuery&lt;HallBanquet&gt;(das.UOW))
join hbi in (new XPQuery&lt;HallBanquetItem&gt;(das.UOW)) on hb.DocId equals hbi.HallBanquet
join cus in (new XPQuery&lt;Customer&gt;(das.UOW)) on hb.Customer equals cus.MastId
select new
{
hb.DocId,
hb.Site,
hb.DocNo,
hb.RefNo,
hb.DocDt,
hb.Customer, 
hb.NoOfPax, 
hb.PartyDate, 
hb.FromTime, 
hb.ToTime, 
hb.MainMenu, 
hb.OfferPackage,
hb.Currency, 
hb.CurRate, 
hb.LPONo, 
hb.LPODate, 
hb.ExpectedDeliveryDt, 
hb.RoundOff, 
hb.SubTotal,
hb.NetAmount, 
hb.Remarks, 
hbi.SeqNo, 
hbi.HallBanquet,
hbi.ItemType, 
hbi.Code, 
Desc = hbi.Description,
hbi.Item, 
hbi.Pkg, 
hbi.Unit, 
hbi.Qty, 
hbi.Price,
hbi.Cost, 
hbi.DiscountPer, 
hbi.DiscountAmt, 
hbi.Amount, 
hbi.TotalAmt, 
hbi.IsInclussiveTax, 
hbi.TaxCd,
hbi.TaxPer, 
hbi.TaxAmt, 
hbi.GlCode, 
cus.Description
};

The error is thrown on the second line at join

  1. HallBanquet Class :

    public class HallBanquet : Epimonos.BizObjects.Core.XPDocumentObject
    {
    public HallBanquet(Session session) : base(session)
    {
    // This constructor is used when an object is loaded from a persistent storage.
    // Do not place any code here.
    }
    public override void AfterConstruction()
    {
    base.AfterConstruction();
    // Place here your initialization code.
    }
    public override void Initialize(RstUser LoginUser, RstSite LoginSite)
    {

         }
    public override void AfterDisplay(RstUser LoginUser, RstSite LoginSite)
    {
    UpdateTotals();
    }
    private Customer _Customer;       
    [RValidate(&quot;Customer&quot;, true, 0)]
    public Customer Customer
    {
    get { return _Customer; }
    set {
    SetPropertyValue&lt;Customer&gt;(nameof(Customer), ref _Customer, value);
    if (!IsLoading &amp;&amp; !IsSaving)
    {
    this.Branch = null;
    this.Contact = null;
    //this.Currency = GetCompanyCurrency(this.Site.Company);
    this.Currency = Site?.Company?.CompanyCurrencies.FirstOrDefault(e =&gt; e.Currency == this.Customer?.Currency);
    }
    }
    }
    private CustomerBranch _Branch;
    [RValidate(&quot;Branch&quot;, false, 0)]
    public CustomerBranch Branch
    {
    get { return _Branch; }
    set
    {
    SetPropertyValue&lt;CustomerBranch&gt;(nameof(Branch), ref _Branch, value);
    if (!IsLoading &amp;&amp; !IsSaving)
    {
    this.Contact = null;
    }
    }
    }
    private CustomerContact _Contact;
    [RValidate(&quot;Contact&quot;,false,0)]
    public CustomerContact Contact
    {
    get { return _Contact; }
    set { SetPropertyValue&lt;CustomerContact&gt;(nameof(Contact), ref _Contact, value); }
    }
    private string _ContactTel;
    public string ContactTel
    {
    get { return _ContactTel; }
    set { SetPropertyValue&lt;string&gt;(nameof(ContactTel), ref _ContactTel, value); }
    }
    private decimal _NoOfPax;
    [RValidate(&quot;NoOfPax&quot;, true, 0)]
    public decimal NoOfPax
    {
    get { return _NoOfPax; }
    set { SetPropertyValue&lt;decimal&gt;(nameof(NoOfPax), ref _NoOfPax, value); }
    }
    private DateTime _PartyDate = DateTime.Today;
    public DateTime PartyDate
    {
    get { return _PartyDate; }
    set { SetPropertyValue&lt;DateTime&gt;(nameof(PartyDate), ref _PartyDate, value); }
    }
    private DateTime _FromTime = DateTime.Parse(&quot;12:00&quot;);
    public DateTime FromTime
    {
    get { return _FromTime; }
    set { SetPropertyValue&lt;DateTime&gt;(nameof(FromTime), ref _FromTime, value); }
    }
    private DateTime _ToTime=DateTime.Parse(&quot;12:00&quot;);
    public DateTime ToTime
    {
    get { return _ToTime; }
    set { SetPropertyValue&lt;DateTime&gt;(nameof(ToTime), ref _ToTime, value); }
    }
    private FoodPkg _MainMenu;
    [RValidate(&quot;MainMenu&quot;, true, 0)]
    public FoodPkg MainMenu
    {
    get { return _MainMenu; }
    set { SetPropertyValue&lt;FoodPkg&gt;(nameof(MainMenu), ref _MainMenu, value); }
    }
    private string _OfferPackage;
    [Size(50)]
    public string OfferPackage
    {
    get { return _OfferPackage; }
    set { SetPropertyValue&lt;string&gt;(nameof(OfferPackage), ref _OfferPackage, value); }
    }
    private RstCompanyCurrency _Currency;
    [RValidate(&quot;Currency&quot;, true, 0 )]
    public RstCompanyCurrency Currency
    {
    get { return _Currency; }
    set { SetPropertyValue&lt;RstCompanyCurrency&gt;(nameof(Currency), ref _Currency, value);
    if (!IsLoading &amp;&amp; !IsSaving)
    {
    this.CurRate = value == null ? 0 : value.CurRate;
    }
    }
    }
    private Double _CurRate;
    [CustomValidation(typeof(VcCommon), &quot;ValidateCurrencyRate&quot;)]
    public Double CurRate
    {
    get { return _CurRate; }
    set { SetPropertyValue&lt;Double&gt;(nameof(CurRate), ref _CurRate, value); }
    }
    private string _LPONo;
    [Size(50)]
    [RValidate(&quot;LPO No&quot;, false ,50 )]
    public string LPONo
    {
    get { return _LPONo; }
    set { SetPropertyValue&lt;string&gt;(nameof(LPONo), ref _LPONo, value); }
    }
    private DateTime _LPODate = DateTime.Today;        
    public DateTime LPODate
    {
    get { return _LPODate; }
    set { SetPropertyValue&lt;DateTime&gt;(nameof(LPODate), ref _LPODate, value); }
    }
    private DateTime _ExpectedDeliveryDt;        
    public DateTime ExpectedDeliveryDt
    {
    get { return _ExpectedDeliveryDt; }
    set { SetPropertyValue&lt;DateTime&gt;(nameof(ExpectedDeliveryDt), ref _ExpectedDeliveryDt, value); }
    }
    private Decimal _CustomerBalance;        
    [NonPersistent]
    public Decimal CustomerBalance
    {
    get { return _CustomerBalance; }
    set { SetPropertyValue&lt;Decimal&gt;(nameof(CustomerBalance), ref _CustomerBalance, value); }
    }
    private Decimal _RoundOff;
    [CustomValidation(typeof(VcCommon), &quot;ValidateRoundOff&quot;)]
    public Decimal RoundOff
    {
    get { return _RoundOff; }
    set { SetPropertyValue&lt;Decimal&gt;(nameof(RoundOff), ref _RoundOff, value);
    UpdateTotals();
    }
    }
    private Decimal _SubTotal;       
    public Decimal SubTotal
    {
    get { return _SubTotal; }
    set { SetPropertyValue&lt;Decimal&gt;(nameof(SubTotal), ref _SubTotal, value); }
    }
    private Decimal _NetAmount;       
    public Decimal NetAmount
    {
    get { return _NetAmount; }
    set { SetPropertyValue&lt;Decimal&gt;(nameof(NetAmount), ref _NetAmount, value); }
    }
    private string _Remarks;
    [Size(SizeAttribute.Unlimited)]
    public string Remarks
    {
    get { return _Remarks; }
    set { SetPropertyValue&lt;string&gt;(nameof(Remarks), ref _Remarks, value); }
    }
    [DevExpress.Xpo.Association(&quot;HallBanquet-Item&quot;), Aggregated()]
    public XPCollection&lt;HallBanquetItem&gt; HallBanquetItems
    {
    get
    {
    XPCollection&lt;HallBanquetItem&gt; col = GetCollection&lt;HallBanquetItem&gt;(nameof(HallBanquetItems));
    if (col.Sorting.Count == 0)
    {
    col.Sorting.Add(new DevExpress.Xpo.SortProperty(&quot;SeqNo&quot;, SortingDirection.Ascending));
    }
    return col;
    }
    }
    public void UpdateTotals()
    {
    if (IsLoading || IsSaving) return;
    Decimal netAmt = 0;
    Decimal taxAmt = 0;
    foreach (var item in this.HallBanquetItems)
    {
    if (!item.IsDeleting)
    {  
    netAmt += item.TotalAmt;                    
    }
    }
    _NetAmount = CommonFx.Round((netAmt + this.RoundOff), this.Currency?.Currency);
    _SubTotal = CommonFx.Round((netAmt-taxAmt), this.Currency?.Currency);
    }
    }
    
  2. HallBanquetItem Class (Child Table)

    public class HallBanquetItem : XPDocumentDet
    {
    public HallBanquetItem(Session session) : base(session)
    {
    // This constructor is used when an object is loaded from a persistent storage.
    // Do not place any code here.
    }

         public override void AfterConstruction()
    {
    base.AfterConstruction();
    // Place here your initialization code.
    }
    private HallBanquet _HallBanquet;
    [Association(&quot;HallBanquet-Item&quot;)]
    public HallBanquet HallBanquet
    {
    get { return _HallBanquet; }
    set { SetPropertyValue&lt;HallBanquet&gt;(nameof(HallBanquet), ref _HallBanquet, value); }
    }
    private RstConstants _ItemType;
    public RstConstants ItemType
    {
    get { return _ItemType; }
    set { SetPropertyValue&lt;RstConstants&gt;(nameof(ItemType), ref _ItemType, value);
    ItmTypeDs = value?.Description;
    }
    }
    private string ItmTypeDs { get; set; }
    private string _Code;
    [Size(50)]
    //[RValidate(&quot;Code&quot;, true, 50)]
    public string Code
    {
    get { return _Code; }
    set { SetPropertyValue&lt;string&gt;(nameof(Code), ref _Code, value); }
    }
    private string _Description;
    [Size(200)]
    //[RValidate(&quot;Description&quot;, true, 200)]
    public string Description
    {
    get { return _Description; }
    set { SetPropertyValue&lt;string&gt;(nameof(Description), ref _Description, value); }
    }
    private Guid _Item;
    public Guid Item
    {
    get { return _Item; }
    set { SetPropertyValue&lt;Guid&gt;(nameof(Item), ref _Item, value);
    }
    }
    private float _Pkg = 1;
    public float Pkg
    {
    get { return _Pkg; }
    set
    {
    SetPropertyValue&lt;float&gt;(nameof(Pkg), ref _Pkg, value);
    }
    }
    private string _Unit;
    [Size(50)]
    //[RValidate(&quot;Unit&quot;, true,50 )]
    public string Unit
    {
    get { return _Unit; }
    set { SetPropertyValue&lt;string&gt;(nameof(Unit), ref _Unit, value); }
    }
    private Decimal _Qty = 1;
    public Decimal Qty
    {
    get { return _Qty; }
    set
    {
    SetPropertyValue&lt;Decimal&gt;(nameof(Qty), ref _Qty, value);
    SetTaxAndSalesAmount();
    }
    }
    private Decimal _Price;
    public Decimal Price
    {
    get { return _Price; }
    set
    {
    SetPropertyValue&lt;Decimal&gt;(nameof(Price), ref _Price, value);
    SetTaxAndSalesAmount();
    }
    }
    private float _Cost;
    public float Cost
    {
    get { return _Cost; }
    set { SetPropertyValue&lt;float&gt;(nameof(Cost), ref _Cost, value); }
    }
    private Decimal _DiscountPer;
    public Decimal DiscountPer
    {
    get { return _DiscountPer; }
    set
    {
    SetPropertyValue&lt;Decimal&gt;(nameof(DiscountPer), ref _DiscountPer, value);
    this.DiscountAmt = Math.Round(((Price * Qty) * value) / 100, 3, MidpointRounding.AwayFromZero);
    }
    }
    private Decimal _DiscountAmt;
    public Decimal DiscountAmt
    {
    get { return _DiscountAmt; }
    set
    {
    SetPropertyValue&lt;Decimal&gt;(nameof(DiscountAmt), ref _DiscountAmt, value);
    SetTaxAndSalesAmount();
    }
    }
    private Decimal _Amount;
    public Decimal Amount
    {
    get { return _Amount; }
    set { SetPropertyValue&lt;Decimal&gt;(nameof(Amount), ref _Amount, value); }
    }
    private Decimal _TotalAmt;
    public Decimal TotalAmt
    {
    get { return _TotalAmt; }
    set { SetPropertyValue&lt;Decimal&gt;(nameof(TotalAmt), ref _TotalAmt, value); }
    }
    private Boolean _IsInclussiveTax;
    public Boolean IsInclussiveTax
    {
    get { return _IsInclussiveTax; }
    set { SetPropertyValue&lt;Boolean&gt;(nameof(IsInclussiveTax), ref _IsInclussiveTax, value); }
    }
    private Tax _TaxCd;
    public Tax TaxCd
    {
    get { return _TaxCd; }
    set
    {
    SetPropertyValue&lt;Tax&gt;(nameof(TaxCd), ref _TaxCd, value);
    this.TaxPer = value == null ? 0 : value.TaxValue;
    }
    }
    private Decimal _TaxPer;
    public Decimal TaxPer
    {
    get { return _TaxPer; }
    set
    {
    SetPropertyValue&lt;Decimal&gt;(nameof(TaxPer), ref _TaxPer, value);
    SetTaxAndSalesAmount();
    }
    }
    private Decimal _TaxAmt;
    public Decimal TaxAmt
    {
    get { return _TaxAmt; }
    set { SetPropertyValue&lt;Decimal&gt;(nameof(TaxAmt), ref _TaxAmt, value); }
    }
    private Account _GlCode;
    public Account GlCode
    {
    get { return _GlCode; }
    set { SetPropertyValue&lt;Account&gt;(nameof(GlCode), ref _GlCode, value); }
    }
    private void SetTaxAndSalesAmount()
    {
    if (!IsLoading &amp;&amp; !IsSaving)
    {
    this.TaxAmt = Math.Round(CommonFx.GetTaxAmount(this.IsInclussiveTax, this.TaxPer, ((this.Price * this.Qty) - this.DiscountAmt)), 3);
    this.Amount = Math.Round(CommonFx.GetTaxableAmount(this.IsInclussiveTax, this.TaxPer, ((this.Price * this.Qty) - this.DiscountAmt)), 3);
    this.TotalAmt = Math.Round(CommonFx.GetAmountWithTax(this.IsInclussiveTax, this.TaxPer, ((this.Price * this.Qty) - this.DiscountAmt)), 3);
    }
    }
    }
    
  3. Customer Tabe

    public class Customer : Epimonos.BizObjects.Core.XPMasterObject
    {

         public Customer(Session session) : base(session)
    {
    // This constructor is used when an object is loaded from a persistent storage.
    // Do not place any code here.
    }
    public override void AfterConstruction()
    {
    base.AfterConstruction();
    // Place here your initialization code.
    }
    public override void Initialize(RstUser LoginUser, RstSite LoginSite)
    {
    _VATRegion = VATRegion.Domestic;
    }
    public override void AfterDisplay(RstUser LoginUser, RstSite LoginSite)
    {
    ///Value assigned after display
    }
    #region Properties
    private string _ShortDs;
    [Size(10)]
    [RValidate(&quot;Short Description&quot;,true ,10 )]
    public string ShortDs
    {
    get { return _ShortDs; }
    set { SetPropertyValue&lt;string&gt;(nameof(ShortDs), ref _ShortDs, value); }
    }
    private CustomerGroup _Parent;
    public CustomerGroup Parent
    {
    get { return _Parent; }
    set { SetPropertyValue&lt;CustomerGroup&gt;(nameof(Parent), ref _Parent, value); }
    }
    private RstCurrency _Currency;       
    public RstCurrency Currency
    {
    get { return _Currency; }
    set { SetPropertyValue&lt;RstCurrency&gt;(nameof(Currency), ref _Currency, value); }
    }
    private string _IDNumber;
    [Size(50)]
    [RValidate(&quot;ID. Number&quot;,false , 50)]
    public string IDNumber
    {
    get { return _IDNumber; }
    set { SetPropertyValue&lt;string&gt;(nameof(IDNumber), ref _IDNumber, value); }
    }
    private string _CustomerType;
    [Size(30)]
    [RValidate(&quot;CustomerType&quot;,false, 30)]
    public string CustomerType
    {
    get { return _CustomerType; }
    set { SetPropertyValue&lt;string&gt;(nameof(CustomerType), ref _CustomerType, value); }
    }
    [NonPersistent]
    private RstBaseType _BaseType;
    public RstBaseType BaseType
    {
    get { return _BaseType; }
    set { SetPropertyValue&lt;RstBaseType&gt;(nameof(BaseType), ref _BaseType, value); }
    }
    private VATRegion _VATRegion;
    public VATRegion VATRegion
    {
    get { return _VATRegion; }
    set { SetPropertyValue&lt;VATRegion&gt;(nameof(VATRegion), ref _VATRegion, value); }
    }
    private string _VATNumber;
    [Size(50)]
    [RValidate(&quot;VAT Number&quot;,false , 50)]
    public string VATNumber
    {
    get { return _VATNumber; }
    set { SetPropertyValue&lt;string&gt;(nameof(VATNumber), ref _VATNumber, value); }
    }
    private DateTime _VATStartDt;
    public DateTime VATStartDt
    {
    get { return _VATStartDt; }
    set { SetPropertyValue&lt;DateTime&gt;(nameof(VATStartDt), ref _VATStartDt, value); }
    }
    private DateTime _ContractExpiry = DateTime.Today;
    public DateTime  ContractExpiry
    {
    get { return _ContractExpiry; }
    set { SetPropertyValue&lt;DateTime &gt;(nameof(ContractExpiry), ref _ContractExpiry, value); }
    }
    private bool _ShowPriceInDN;
    public bool ShowPrice
    {
    get { return _ShowPriceInDN; }
    set { SetPropertyValue&lt;bool&gt;(nameof(ShowPrice), ref _ShowPriceInDN, value); }
    }
    /// &lt;summary&gt;
    /// Mannual blocking of Customer from Transaction
    /// &lt;/summary&gt; _BlockCustomer
    private bool _BlockCustomer;         
    public bool BlockCustomer
    {
    get { return _BlockCustomer; }
    set { SetPropertyValue&lt;bool&gt;(nameof(BlockCustomer), ref _BlockCustomer, value);
    if (!IsLoading &amp;&amp; !IsSaving &amp;&amp; !BlockCustomer) _BlockedReason = &quot;&quot;;
    }
    }
    private string _BlockedReason;
    [Size(100)]
    [RValidate(&quot;Blocked Reason&quot;,false ,100 )]
    public string BlockedReason
    {
    get { return _BlockedReason; }
    set { SetPropertyValue&lt;string&gt;(nameof(BlockedReason), ref _BlockedReason, value); }
    }
    private string _PaymentTerms;
    [Size(30)]
    [RValidate(&quot;Payment Terms&quot;,false , 30)]
    public string PaymentTerms
    {
    get { return _PaymentTerms; }
    set { SetPropertyValue&lt;string&gt;(nameof(PaymentTerms), ref _PaymentTerms, value); }
    }
    private string _DeliveryTerms;
    [Size(30)]
    [RValidate(&quot;DeliveryTerms&quot;,false , 30)]
    public string DeliveryTerms
    {
    get { return _DeliveryTerms; }
    set { SetPropertyValue&lt;string&gt;(nameof(DeliveryTerms), ref _DeliveryTerms, value); }
    }
    private Account _CustomerLedger;
    public Account CustomerLedger
    {
    get { return _CustomerLedger; }
    set { SetPropertyValue&lt;Account&gt;(nameof(CustomerLedger), ref _CustomerLedger, value); }
    }
    private Account _AdvanceLedger;
    public Account AdvanceLedger
    {
    get { return _AdvanceLedger; }
    set { SetPropertyValue&lt;Account&gt;(nameof(AdvanceLedger), ref _AdvanceLedger, value); }
    }
    private Boolean _IsSubCustomer;
    public Boolean IsSubCustomer
    {
    get { return _IsSubCustomer; }
    set
    {
    SetPropertyValue&lt;Boolean&gt;(nameof(IsSubCustomer), ref _IsSubCustomer, value);
    if (!IsLoading &amp;&amp; !IsSaving &amp;&amp; !IsSubCustomer) _ParentCustomer = null;
    }
    }
    private Customer _ParentCustomer;
    public Customer ParentCustomer
    {
    get { return _ParentCustomer; }
    set { SetPropertyValue&lt;Customer&gt;(nameof(ParentCustomer), ref _ParentCustomer, value); }
    }
    private bool _IsCreditLimitCheck;
    public bool IsCreditLimitCheck
    {
    get { return _IsCreditLimitCheck; }
    set
    {
    SetPropertyValue&lt;bool&gt;(nameof(IsCreditLimitCheck), ref _IsCreditLimitCheck, value);
    if (!IsCreditLimitCheck)
    {
    _CreditPeriod = 0;
    _CreditLimit = 0;
    }
    }
    }
    private int _CreditPeriod;
    public int CreditPeriod
    {
    get { return _CreditPeriod; }
    set { SetPropertyValue&lt;int&gt;(nameof(CreditPeriod), ref _CreditPeriod, value); }
    }
    private Decimal _CreditLimit;
    public Decimal CreditLimit
    {
    get { return _CreditLimit; }
    set { SetPropertyValue&lt;Decimal&gt;(nameof(CreditLimit), ref _CreditLimit, value); }
    }
    private SalesMan _SalesMan;
    public SalesMan SalesMan
    {
    get { return _SalesMan; }
    set { SetPropertyValue&lt;SalesMan&gt;(nameof(SalesMan), ref _SalesMan, value); }
    }
    #endregion
    #region Associations
    [Association(&quot;Customer-CustomerBranch&quot;)]
    public XPCollection&lt;CustomerBranch&gt; CustomerBranches
    {
    get
    {
    XPCollection&lt;CustomerBranch&gt; col = GetCollection&lt;CustomerBranch&gt;(nameof(CustomerBranches));
    if (col.Sorting.Count == 0)
    {
    col.Sorting.Add(new DevExpress.Xpo.SortProperty(&quot;SeqNo&quot;, SortingDirection.Ascending));
    }
    return col;
    }
    }
    private XPCollection&lt;CustomerBranch&gt; _ActiveBranches;
    public XPCollection&lt;CustomerBranch&gt; ActiveBranches
    {
    get
    {
    return _ActiveBranches;
    }
    }
    [Association(&quot;Customer-CustomerContact&quot;)]
    public XPCollection&lt;CustomerContact&gt; CustomerContacts
    {
    get
    {
    XPCollection&lt;CustomerContact&gt; col = GetCollection&lt;CustomerContact&gt;(nameof(CustomerContacts));
    if (col.Sorting.Count == 0)
    {
    col.Sorting.Add(new DevExpress.Xpo.SortProperty(&quot;SeqNo&quot;, SortingDirection.Ascending));
    }
    return col;
    }
    }
    public XPCollection&lt;CustomerContact&gt; ActiveCustContacts(Guid? BranchID)
    {
    if (BranchID != null)
    {
    return new XPCollection&lt;CustomerContact&gt;(this.Session, CriteriaOperator.Parse($&quot;Customer = &#39;{this.MastId}&#39;AND Active AND CustomerBranch.RowId=&#39;{BranchID}&#39; &quot;),
    new SortProperty(&quot;SeqNo&quot;, SortingDirection.Ascending));
    }
    else
    {
    return new XPCollection&lt;CustomerContact&gt;(this.Session, CriteriaOperator.Parse($&quot;Customer = &#39;{this.MastId}&#39;AND Active&quot;),
    new SortProperty(&quot;SeqNo&quot;, SortingDirection.Ascending));
    }
    }
    #endregion
    }
    

答案1

得分: 1

在第2行,你可能应该写hb.DocId equals hbi.HallBanquetId或者hb.DocId equals hbi.DocId,而不是hb.DocId equals hbi.HallBanquet(这取决于你的外键从项目指向宴会的命名方式)。

英文:

Probably, in the 2nd line you should write hb.DocId equals hbi.HallBanquetId or hb.DocId equals hbi.DocId instead of hb.DocId equals hbi.HallBanquet (It depends on how your foreign key pointing from item to banquet is named).

huangapple
  • 本文由 发表于 2023年2月8日 16:24:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/75382997.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定