我有两个模型列表,我想添加到第三个模型列表中,但出现错误- No overload for method "Add" takes two arguments
。这是我的代码:
List<TableNotificationModel> one = JsonConvert.DeserializeObject<List<TableNotificationModel>>(cmdPositive);
List<TableNotificationModel> two = JsonConvert.DeserializeObject<List<TableNotificationModel>>(cmdNegative);
List<TableNotificationModel> three = new List<TableNotificationModel>();
three.Add(one, two);
IEnumerable<TableNotificationModel> result = three;
DataSourceResult dataSource = result.ToDataSourceResult(request);
我想将列表设置result
为的值,three
以便在下面使用它。我尝试使用AddRange
代替,Add
但它抛出相同的错误。我实习生告诉我的一些开发人员,Dictionary
但我不知道如何使用字典来解决。
我试过这样的东西,three.Add(one)
但它说cannot convert generic list to model
。
关于如何进行的任何建议?
这是否应该只是项目(联合)的平面列表:
var one = JsonConvert.DeserializeObject<List<TableNotificationModel>>(cmdPositive);
var two = JsonConvert.DeserializeObject<List<TableNotificationModel>>(cmdNegative);
var three = one.Union(two).ToList();
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句