Dynamic Anonymous type in Razor causes RuntimeBinderException

后端 未结 12 932
不思量自难忘°
不思量自难忘° 2020-11-22 07:45

I\'m getting the following error:

\'object\' does not contain a definition for \'RatingName\'

When you look at the anonymous dyn

12条回答
  •  耶瑟儿~
    2020-11-22 07:55

    You can use the framework impromptu interface to wrap an anonymous type in an interface.

    You'd just return an IEnumerable and at the end of your Linq use .AllActLike(); this works because it calls the anonymous property using the DLR with a context of the assembly that declared the anonymous type.

提交回复
热议问题