c# - 如何使用数组中的对象在 dotnet (C#) 文档中建模
问题描述
我的 MongoDB 中有下一个西班牙语文档:
{
"Cabecera": [{
"NumGuia": "9672",
"OC": "1234",
"Fecha_Compra": "2020-03-21"
}],
"Detalle": [{
"Cantidad": 1,
"Obs": ""
}],
"Item": [{
"CodAct": " ",
"Serie": "",
"CodInt": "",
"Precio": "1.00",
"UniPrecio": "USD"
}],
"Plantilla": [{
"Nombre": "GUANTE DESCARTABLE AZUL T L",
"Descripcion": " ",
"Naturaleza": 2,
"Peso": "0.0000",
"UniPeso": 1,
"CodBar": "",
"NumPar": "1000006585",
"Caja": false,
"stockCri": 1000,
"stockMax": 4000,
"Precio": "1.00",
"UniMonetaria": "USD",
"NumPartCli": "",
"Critica": false,
"Epp": false,
"Calibracion": false
}],
"Marca": [{
"Nombre": "ANSELL"
}],
"Categoria": [{
"Nombre": "EPP",
"Tipo": 2
}],
"SubCategoria": [{
"Nombre": "ADHESIVO"
}]
这表明对于每个修复,在位置零处都有一个具有属性的对象。我的问题是能够在 dotnet core 的 web api 项目中创建“模型”类。由于我无法对每个数组中的数组和对象进行建模,因此我无法使用与此 Web API 相关的 CRUD ...
知道如何在我的 model.cs 类中对该文档建模有任何帮助吗?
PD:这是我目前在我的班级 mode.cs 中的内容:
[BsonId]
[BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
public BsonIdAttribute id { get; set; }
//array cabecera
[BsonRepresentation(MongoDB.Bson.BsonType.Array)]
public Array Cabecera { get; set; }
public string NumGuia { get; set; }
public string OC { get; set; }
public string Fecha_Compra { get; set; }
//array Detalle
[BsonRepresentation(MongoDB.Bson.BsonType.Array)]
public Array Detalle { get; set; }
public int Cantidad { get; set; }
public string Obs { get; set; }
//array Item
[BsonRepresentation(MongoDB.Bson.BsonType.Array)]
public Array Item { get; set; }
public string CodAct { get; set; }
public string Serie { get; set; }
public string CodInt { get; set; }
public string Precio { get; set; }
public string UniPrecio { get; set; }
//array Plantilla
[BsonRepresentation(MongoDB.Bson.BsonType.Array)]
public Array Plantilla { get; set; }
public string Nombre { get; set; }
public string Descripcion { get; set; }
public int Naturaleza { get; set; }
public string Peso { get; set; }
public int UniPeso { get; set; }
public string CodBar { get; set; }
public string NumPar { get; set; }
public bool Caja { get; set; }
public int stockCri { get; set; }
public int stockMax { get; set; }
public string PrecioP { get; set; }
public string UniMonetaria { get; set; }
public string NumPartCli { get; set; }
public bool Critica { get; set; }
public bool Epp { get; set; }
public bool Calibracion { get; set; }
//array Marca
[BsonRepresentation(MongoDB.Bson.BsonType.Array)]
public Array Marca { get; set; }
public string Nombre { get; set; }
//array Categoria
[BsonRepresentation(MongoDB.Bson.BsonType.Array)]
public Array Categoria { get; set; }
public string Nombre { get; set; }
public int Tipo { get; set; }
//array SubCategoria
[BsonRepresentation(MongoDB.Bson.BsonType.Array)]
public Array SubCategoria { get; set; }
public string Nombre { get; set; }
}
解决方案
推荐阅读
- javascript - 在 Javascript 中调整图像大小后如何获取图像文件大小?
- python - TCP 服务器不接收全部数据
- python - 如何将协程添加到正在运行的事件循环中?
- angular - Observable 没有完整显示值
- c# - 如何解决这个格式化日期字符串:
- javascript - 带有有效载荷的 mapActions
- django - 跨多个模型的外键过滤
- winforms - 将 AutocompleteMode 设置为 Suggest 无效
- javascript - 除了最后一个之外,所有数组元素都未定义?
- php - 在php中从一个数组动态插入一个值到另一个数组