Asp.net mvc models without databases/framework

后端 未结 2 1826
别那么骄傲
别那么骄傲 2021-01-14 18:13

Are there any tutorials/examples on how to create an asp.net mvc app without the model being managed by a database (through linq2sql or entity framework). I\'ve to create a

相关标签:
2条回答
  • 2021-01-14 18:50

    MVC 3 has extra support for JSON which you might want to look into.

    Or use the futures with MVC 2.

    0 讨论(0)
  • 2021-01-14 19:10

    I agree that most of the examples/tutorials out there are using entity framework. This being said the process would be similar:

    1. Create your model classes.
    2. Create a repository working with those model classes. This repository should implement an interface which contains all the operations you need with those models like GetUser, SaveUser, etc... In the implementation you connect to the remote JSON API server to fetch data.
    3. You create a controller which takes the repository interface in the constructor. Setup a custom controller factory so that a DI framework could provide instances of your controllers.
    4. Define views and view model classes.
    5. Controller actions talk to the repository via the provided interface to fetch models, maps those models to view models and returns them to the corresponding view to be shown.

    Useful tools:

    • MvcContrib (many useful helpers)
    • AutoMapper (for mapping between models and view models)
    • FluentValidation.NET (for validating models)
    0 讨论(0)
提交回复
热议问题