简体   繁体   English

不为模型使用实体框架

[英]Not using Entity Framework for models

I'm going to try and use MVC4 for an ASP.NET web portal (first time I'll use ASP's MVC), but I don't think the models will be using Entity Framework much. 我将尝试将MVC4用于ASP.NET Web门户(第一次使用ASP的MVC),但是我认为模型不会大量使用Entity Framework。

Perhaps only the Users model will, which will contain user profile data, but most of the data presented to the users will either come from Sharepoint or CRM 2011 . 也许只有Users模型会包含用户配置文件数据,但是提供给用户的大多数数据将来自SharepointCRM 2011

So essentially, my models are going to be Sharepoint items and CRM entities. 因此,基本上,我的模型将是Sharepoint项目和CRM实体。

I looked at the sample application provided by MVC4 (title Internet Application in the templates) and I see that the model uses EF ( AccountModel.cs ). 我查看了MVC4提供的示例应用程序(模板中的标题为Internet Application ),并且看到该模型使用EF( AccountModel.cs )。

Is this a requirement as per MVC4's best practices or you can build models from any source you wish and still be within the "best practices" ? 根据MVC4的最佳实践,这是否是一项要求?或者您可以从任何所需的来源构建模型,并且仍属于“最佳实践”之内?

Do you see any obvious "no-no's" of using MVC4 judging by the requirements of the portal application I'll have to build ? 从我必须构建的门户网站应用程序的需求来看,您是否看到使用MVC4的明显“不行”?

I'm thinking of using some rich content JavaScript library for the UI (Knockout, ExtJS, etc.) 我正在考虑为UI使用一些内容丰富的JavaScript库(Knockout,ExtJS等)

Thanks. 谢谢。

A model is just a representation of your data that you pass to the view. 模型只是传递给视图的数据的表示形式。 It can be anything you want, and definitely does not have to come from the Entity Framework. 它可以是任何您想要的东西,并且绝对不必来自实体框架。

public class MyModel
{
  public string Name {get;set;}
}

public class MyController
{
  public ActionResult MyAction
  {
     var account = service.GetCrmEntity("account", myaccountId);

     var myModel = new MyModel();
     myModel.Name = account.name;

     return View(myModel)
  }
}

It was built to aid the feature; 它是为辅助功能而构建的。 I don't know if the model is an area to be concerned about best practices. 我不知道该模型是否是要关注最佳实践的领域。 A model should just contain the data to send to the view. 模型应该只包含要发送到视图的数据。

Note: if you use knockout, your app will do away with server-side models in favor of client-side models in JavaScript; 注意:如果您使用敲除功能,则您的应用将取消服务器端模型,而转而使用JavaScript中的客户端模型; the whole paradigm is different when you shift to the client-side. 当您转移到客户端时,整个范例是不同的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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