简体   繁体   中英

C# dynamic keyword usage in ASP.NET MVC

I'm new to .NET 4 and ASP.NET MVC. I heard that in ASP.NET MVC 3, dynamic object can be created on the fly (ie an entity representing data from SQL Server) and returned for use in views. Can someone point me to an example of how this is done?

Your views in MVC3 have a Model object which is dynamic if your don't specify a type using the @model keyword. But if the object you return from your controller to your view doesn't have the data it won't magically be present in your view.

The closest thing to what i think you mean would be the Microsoft.Data api in WebMatrix where you just make arbitrary sql queries and get a dynamic object returned which contains fields that correspond to the data structure of your database table ...

Rob connery talks about it here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM