且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将动态元素添加到.NET MVC中已存在的模型中

更新时间:2023-12-01 20:35:52

因此,对于以后寻找此解决方案的任何人,由于找不到解决方案,我最终使用了一种变通方法.

So, to anyone looking for this in the future, I ended up using a workaround as I didn't find a solution to this problem.

我没有动态模型,而是重新编写了"Result"类,如下所示:

Instead of having a dynamic model, I rewrote the 'Result' class as follow :

    public class Result
    {
        public List<KeyValuePair<string, string>> values { get; set; }
    } 

当我从API接收数据时可以填写.

that I can fill as I receive the data from the API.

这会使视图中的数据处理变得更加烦人,但实际上还不错.

It makes for slightly more annoying data handling in the view, but it's really not that bad.

P.s.我没有将其标记为答案,因为这只是一个不错的解决方法

P.s. I'm not marking this as answer as it is just a nice workaround