.net - Many to Many Relationship Objects in C# Part 2 -
I am using .NET 2.0. I have 2 objects: PhoneService and the second chart chart. The relationship between this is much more than many.
Public category phone service (Personal list & chart; Chart account> chartAccounts; Private chart account list account; Public Int64 ID {Get {return ID;} set {id = value }}} Public bool update () {...} public square charts Aaccount {public Int64 ID {get {return id;} set {id = value;}} Public bool Add () {...} public bool Update () {...} public bool allocation () {// This bridge will save data for table}}
In your customers, I have the following code:
f Neither service = new phone service (Int64.Parse (dataItem.OwnerTableView.DataKeyValues [dataItem.ItemIndex] [ "ServiceID"]. ToString))); If (service.ChartAccounts == faucet) {Allocation Allocation = New Chart Accounting (Int64.Parse (drpdwnlstMainChartAccountAllocation.SelectedValue)); Int i = 0; Foreign Currency Allocation (Allotment ITEM Allocation Items in Allocation.) {Service.ChartAccounts [i] .name = AllocationItem. Value2; Service.ChartAccounts [i] .SplitPercentage = Decimal.Parse (Allocation Item.Value1); Service.Allocate (); I ++; }}
I get an error on the following line, which says that use the "new" keyword to create an object instance. service. Chart account [i] .name = allocationite Value2;
Since CharAccounts is a collection of chart account objects and this service is inside the object, how do I define this thing?
Thanks
In your foreach loop, you are serving .CartAccounts [i] .Name = allocationItem.Value2
, but we do not already know the service.ChartAccounts
(Otherwise you can get the initial if
Before your foreach loop, you need to start the service.ChartAccounts
serviceChartAccounts = new list & lt; ChartAccount & gt; ()
by setting each value First, make a new chart out
before you set its name
property I need to type something like this:
if (service.ChartAccounts == zero) {allocation allocation = new chart account option (Int64.Parse (drpdwnlstMainChartAccountAccountAllocation. SelectedValue); List & lt; ChartAccount & gt; acctList = New list & lt; Chart d'Cont & gt; (); Foreign Currency Allocation Allocation All Items in Allocation {Chart Account acct = New Chart Account (); AcctName = AllocationItem.value2; Acct.SplitPercentage = Decimal Purse (allocationite value1); AcctList.Add (account); } Service.ChartAccounts = acctList; Service.Allocate (); // I do not know what this does, so it can be wrong)
The point of attention is that you make the list, and the chart account
Before using objects.
Comments
Post a Comment