기본적으로 JSON 아래의 "rows"속성 아래에서 데이터를 가져오고 싶습니다 (객체로 직접 역 직렬화).
EF Core를 사용하여 DB에서 유지할 수있는 일부 개체의 배열 JsonConvert.DeserializeObject<'SomeWrapperClass'>(message);
로이 데이터를 가져 오는 데 직접 사용할 수 있도록 어떤 래퍼 클래스를 만들어야합니까 "rows": [ [ 19.545363672276512, "JapanUnifia-Trial", 20180331, "USD" ], [ 173.41979241290323, "RVIIOT-TRIAL", 20180331, "USD" ], [ 20.359416562625452, "VSTSHOL-1595322048000", 20180331, "USD" ] ]
?
{
"id": "providers/Microsoft.Billing/billingAccounts/70664866/enrollmentAccounts/456/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
"name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
"type": "microsoft.costmanagement/Query",
"properties": {
"nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/70664866/enrollmentAccounts/456/providers/Microsoft.CostManagement/Query?api-version=2019-10-01&$skiptoken=AQAAAA%3D%3D",
"columns": [
{
"name": "PreTaxCost",
"type": "Number"
},
{
"name": "ResourceGroup",
"type": "String"
},
{
"name": "UsageDate",
"type": "Number"
},
{
"name": "Currency",
"type": "String"
}
],
"rows": [
[
19.545363672276512,
"JapanUnifia-Trial",
20180331,
"USD"
],
[
173.41979241290323,
"RVIIOT-TRIAL",
20180331,
"USD"
],
[
20.359416562625452,
"VSTSHOL-1595322048000",
20180331,
"USD"
]
]
}
}
https://docs.microsoft.com/en-us/rest/api/cost-management/query/usage 에서 가져온이 샘플 json
rows
속성 을 가져 오는 클래스는 다음과 같습니다 .
public class Properties
{
public List<List<object>> rows { get; set; }
}
public class Root
{
public Properties properties { get; set; }
}
다음 Deserialize
과 Newtonsoft.Json
:
var values = JsonConvert.DeserializeObject<Root>(message).properties.rows;
이 데이터를 db에서 사용하려면 모델 클래스가 있어야합니다.
public class dbModel
{
public double propertyName { get; set; }
// Add other properties
//With the name of db model and view model being valid table names
//the properties being of the same data types as values.rows
}
그리고 View Model 클래스 :
public class dbViewModel
{
public IEnumerable<dbModel> dbModels { get; set; }
//Use this class to Enumerate through the rows
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다