我有一类以下类型,但我不确定如何将多对一组合。我有一个名为Assets的主列表,它可以包含以下内容:
public class Asset
{
public Guid Id { get; set; }
public string Description { get; set; }
public int CurrentValue { get; set; }
public string ValuationDate { get; set; }
public int Owner { get; set; }
public int OutstandingFinance { get; set; }
public int FinanceAccountHolder { get; set; }
public int FinanceMonthlyPayment { get; set; }
public object FinanceEndDate { get; set; }
public bool Home { get; set; }
public int AssetType { get; set; }
public object FixedPeriodEndDate { get; set; }
public int ValuationSource { get; set; }
public int Equity { get; set; }
public bool IsSharedOwnership { get; set; }
public object HousingAssociation { get; set; }
public int HousingAssociationShareOfPropertyPercent { get; set; }
public bool BeneficialInterest { get; set; }
public object JointOwner1 { get; set; }
public object JointOwner2 { get; set; }
public object JointOwner3 { get; set; }
public int RentalIncome { get; set; }
public object AccountNumber { get; set; }
public object PropertySecuredAgainstId { get; set; }
public string FinanceCompany { get; set; }
}
我不需要如何组合以下内容,例如我需要popupulate说哪个被归类为汽车资产但是我需要从其他来源提取数据但是将它们合并到单个类中。
描述 当前值 所有者
但是当然如果我使用List<Asset>
,它最终会为每个部分创建一个新节点
public List<Asset> getallVechiclesForSlate()
{
List<tbl_Vehicle> _vehicle = new List<tbl_Vehicle>();
Asset _asset = new Asset();
_vehicle = dal.GetAllVehiclesByCaseId(caseid);
foreach (var vechicle in _vehicle)
{
CurrentFinance = dal.GetFinanceByVehicleId(vechicle.Vehicle_id);
_asset.Description = vechicle.make + " " + vechicle.model;
_asset.CurrentValue = (int)Math.Round(Convert.ToDouble(vechicle.valueOfVehicle));
if (CurrentFinance.FinanceOutstanding == true)
{
_asset.OutstandingFinance = 0;
}
else
{
_asset.OutstandingFinance = 1;
}
_asset.FinanceMonthlyPayment = (int)Math.Round(Convert.ToDouble(CurrentFinance.MonthlyCost));
}
}
json的示例如下所示的屏幕截图
{
"Id": "1ff540fa-664e-4d06-b972-e768e897f6ed",
"LeadSourceId": "dcb14606-6abd-4bea-886c-c498f65c9e98",
"Reference": "VB90590714",
"FirstName": "Johnny",
"MiddleName": null,
"LastName": "Smith",
"Title": "Miss",
"Gender": 2,
"DateOfBirth": "1980-01-01T00:00:00",
"Occupation": "Supervisor",
"MaritalStatusTypeName": "Single",
"ResidencyTypeName": "Renting",
"ReasonForDifficultyTypeName": "Other",
"ReasonForDifficultyDescription": "due to a reduction in hours. My children are staying in full time education for the time being. Not looking at Uni. Older child has a placement to go to after college so will be getting paid and she has already said that he will have to pay board. This will apply to the younger one when the time comes.",
"HomePhoneNumber": "01234567891",
"WorkPhoneNumber": "01234567891",
"MobilePhoneNumber": "01234567891",
"Email": "",
"Created": "2016-10-11T08:50:20.8337591+01:00",
"TotalUnsecuredDebtLevel": 4999.0,
"JobStartDate": "2016-01-01T00:00:00",
"HaveBankAccount": true,
"BanksWith": "Halifax Plc",
"SalaryPaymentFrequency": 1,
"LivingWithPartner": false,
"IsJoint": false,
"PartnerFirstName": "Joan",
"PartnerLastName": "Smith",
"PartnerDob": "1970-02-02T00:00:00",
"PartnerOccupation": null,
"PartnerEmploymentStatus": 0,
"PartnerTitle": "",
"PartnerMobilePhone": "01234567891",
"PartnerEmail": "phil.carney@drspclaims.co.uk",
"PartnerGender": 0,
"PartnerJobStartDate": null,
"PartnerNiNumber": "CD123456A",
"PartnerSalaryPaymentFrequency": 1,
"MainAddress": {
"AddressOne": "11040 Park Road",
"AddressTwo": "Timperley",
"AddressThree": "Cheshire",
"Postcode": "WA15 1AB"
},
"CorrespondenceAddress": {
"AddressOne": "11040 Park Road",
"AddressTwo": "Timperley",
"AddressThree": "Cheshire",
"Postcode": "WA15 1AB"
},
"EmploymentStatus": 0,
"NiNumber": "AB123456A",
"Debts": [{
"DebtTypeName": "Other",
"AmountOwed": 2609.87,
"MonthlyPayment": 1.0,
"DebtResponsibility": 1,
"CreditorName": "North Somerset Council",
"AccountNumber": "5016522727",
"DebtStatus": "1 Month in arrears",
"Documents": []
}, {
"DebtTypeName": "Other",
"AmountOwed": 1045.63,
"MonthlyPayment": 1.0,
"DebtResponsibility": 1,
"CreditorName": "North Somerset Council",
"AccountNumber": "90517291",
"DebtStatus": "1 Month in arrears",
"Documents": []
}, {
"DebtTypeName": "Other",
"AmountOwed": 1031.61,
"MonthlyPayment": 109.00,
"DebtResponsibility": 1,
"CreditorName": "Argos Card Services",
"AccountNumber": "6335409910455368986",
"DebtStatus": "1 Month in arrears",
"Documents": []
}],
"Dependants": [{
"Dob": "1999-09-17T00:00:00",
"Name": "Bill",
"LivesWith": 0
}, {
"Dob": "1998-03-13T00:00:00",
"Name": "Bill",
"LivesWith": 0
}],
"Documents": [],
"Incomes": [{
"IncomeTypeName": "Child Benefit",
"Frequency": 2,
"Amount": 34
}, {
"IncomeTypeName": "Income from lodger",
"Frequency": 1,
"Amount": 1
}, {
"IncomeTypeName": "Child Maintenance",
"Frequency": 1,
"Amount": 1
}, {
"IncomeTypeName": "Working Tax Credit",
"Frequency": 1,
"Amount": 197
}, {
"IncomeTypeName": "Income Support",
"Frequency": 1,
"Amount": 1
}, {
"IncomeTypeName": "Salary",
"Frequency": 1,
"Amount": 910
}, {
"IncomeTypeName": "Benefits",
"Frequency": 1,
"Amount": 1
}, {
"IncomeTypeName": "Housing Benefit",
"Frequency": 1,
"Amount": 1
}, {
"IncomeTypeName": "State Pension",
"Frequency": 1,
"Amount": 1
}, {
"IncomeTypeName": "Disability Living Allowance",
"Frequency": 1,
"Amount": 1
}, {
"IncomeTypeName": "Self Employment",
"Frequency": 1,
"Amount": 1
}, {
"IncomeTypeName": "Child Tax Credit",
"Frequency": 1,
"Amount": 388
}, {
"IncomeTypeName": "Occupational Pension",
"Frequency": 1,
"Amount": 1
}, {
"IncomeTypeName": "Personal Pension",
"Frequency": 1,
"Amount": 1
}, {
"IncomeTypeName": "Job Seekers Allowance",
"Frequency": 1,
"Amount": 1
}, {
"IncomeTypeName": "Employment Support Allowance",
"Frequency": 1,
"Amount": 1
}, {
"IncomeTypeName": "Incapacity Benefit",
"Frequency": 1,
"Amount": 1
}, {
"IncomeTypeName": "Unspecified",
"Frequency": 1,
"Amount": 1
}, {
"IncomeTypeName": "Carers Allowance",
"Frequency": 1,
"Amount": 1
}, {
"IncomeTypeName": "Partners Salary",
"Frequency": 1,
"Amount": 1
}],
"Expenditures": [{
"ExpenditureTypeName": "Health",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Sundries & Emergencies",
"AmountMonthly": 37
}, {
"ExpenditureTypeName": "Home Help",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Charity",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Business Costs",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Smoking",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Ground Rent",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Applicant2 IVA Contribution",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Electricity",
"AmountMonthly": 60
}, {
"ExpenditureTypeName": "Coal",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Arrears (Accommodation)",
"AmountMonthly": 59
}, {
"ExpenditureTypeName": "Endowments",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Children's Activities",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Life",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Sport, Hobbies & Entertainment",
"AmountMonthly": 44
}, {
"ExpenditureTypeName": "Internet",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "TV Package",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Work Meals",
"AmountMonthly": 42
}, {
"ExpenditureTypeName": "Gas",
"AmountMonthly": 60
}, {
"ExpenditureTypeName": "Rent",
"AmountMonthly": 506
}, {
"ExpenditureTypeName": "Contents",
"AmountMonthly": 9
}, {
"ExpenditureTypeName": "Water",
"AmountMonthly": 47
}, {
"ExpenditureTypeName": "Arrears (Household Bills)",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "School Meals",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "TV Licence",
"AmountMonthly": 12
}, {
"ExpenditureTypeName": "Repairs & Servicing",
"AmountMonthly": 15
}, {
"ExpenditureTypeName": "Income Protection",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Other (Insurance)",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Pets, Pet Food & Insurance",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Child Maintenance",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Vehicle Tax",
"AmountMonthly": 10
}, {
"ExpenditureTypeName": "Non Dependent Child Allowance",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "School Trips & Activities",
"AmountMonthly": 14
}, {
"ExpenditureTypeName": "School Fees & Expenses",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Boiler",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Clothing & Footwear",
"AmountMonthly": 36
}, {
"ExpenditureTypeName": "Breakdown Cover",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Other (Household Bills)",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Child Care",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Buildings",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Professional Fees",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Vehicle Maintenance",
"AmountMonthly": 20
}, {
"ExpenditureTypeName": "Partner Commitments",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "CCJ",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Appliance Rental",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Mortgage Protection",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Service Charge",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Telephone inc. Mobile",
"AmountMonthly": 20
}, {
"ExpenditureTypeName": "Laundry & Dry Cleaning",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Educational Costs",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Waste Collection",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Heating Oil",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "TV Rental",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Other (Accommodation)",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Dentist / Opticians",
"AmountMonthly": 13
}, {
"ExpenditureTypeName": "Secured Homes",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Medicines / Prescriptions",
"AmountMonthly": 12
}, {
"ExpenditureTypeName": "Other (Miscellaneous)",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Sky Insurance Plan",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Storage Fees",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Mobile Phone",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Public Transport",
"AmountMonthly": 40
}, {
"ExpenditureTypeName": "Newspapers & Magazines",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Kit",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Hair",
"AmountMonthly": 26
}, {
"ExpenditureTypeName": "Fuel & Parking",
"AmountMonthly": 55
}, {
"ExpenditureTypeName": "Pocket Money",
"AmountMonthly": 24
}, {
"ExpenditureTypeName": "Food, Toiletries & Cleaning",
"AmountMonthly": 270
}, {
"ExpenditureTypeName": "Gym",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Board",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Credit Union",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Vehicle Finance",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Hire Purchase",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Other (Travel)",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "Vehicle Insurance",
"AmountMonthly": 40
}, {
"ExpenditureTypeName": "Council Tax",
"AmountMonthly": 1
}, {
"ExpenditureTypeName": "DLA",
"AmountMonthly": 1
}],
"Notes": [],
"Assets": [{
"Id": "59426e26-22c8-4a61-8cf2-26f1f901b030",
"Description": "Mini Cooper",
"CurrentValue": 4000,
"ValuationDate": "2016-08-18T00:00:00",
"Owner": 1,
"OutstandingFinance": 0,
"FinanceAccountHolder": 1,
"FinanceMonthlyPayment": 0,
"FinanceEndDate": null,
"Home": false,
"AssetType": 0,
"FixedPeriodEndDate": null,
"ValuationSource": 0,
"Equity": 4000,
"IsSharedOwnership": false,
"HousingAssociation": null,
"HousingAssociationShareOfPropertyPercent": 0,
"BeneficialInterest": false,
"JointOwner1": null,
"JointOwner2": null,
"JointOwner3": null,
"RentalIncome": 0,
"AccountNumber": null,
"PropertySecuredAgainstId": null,
"FinanceCompany": ""
}]
}
编辑2 那么我是否正确地说这将是我采取的确保这一点的方法。
public class Asset : carAsset
{
public Guid Id { get; set; }
}
public class carAsset
{
public string Description { get; set; }
public int CurrentValue { get; set; }
public string ValuationDate { get; set; }
public int Owner { get; set; }
public int OutstandingFinance { get; set; }
public int FinanceAccountHolder { get; set; }
public int FinanceMonthlyPayment { get; set; }
public object FinanceEndDate { get; set; }
public int AccountNumber { get; set; }
}
当我说两个资产总是存在主要资产节点时,我可能会过于复杂化,它们是低于该资产节点的多个资产,即1,2,3与其中的完整资产类别的相同值,但我需要结合班级。