且构网

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

如何使用实体框架从数据库加载行?

更新时间:2023-02-13 14:43:13

Hello MarDude,

Hello MarDude,

我知道入门可能很难。  关于EF的好处是它占用了大量的管道,因此您应该能够直接从您的上下文(或者在您的示例中为ef)访问对象。  换句话说,ef.SalesRepresentatives.First(rep
=> rep.ID = 1);

I understand getting started can be hard.  The nice thing about EF is it takes away a lot of the plumbing so you should be able to access the objects directly off of you context (or ef in your example).  In other words ef.SalesRepresentatives.First(rep => rep.ID = 1);

以下是一些希望有所帮助的帖子:

Here are some posts that will hopefully help:

https://msdn.microsoft.com/en-us/data/jj573936.aspx?f=255&MSPPError=-2147217396

https://msdn.microsoft.com/en-us/data/jj573936.aspx?f=255&MSPPError=-2147217396

这是针对MVC但是说明如何使用EF:

This targets MVC but illustrates how to use EF:

http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/creating-an -entity-framework-data-model-for-an-asp-net-mvc-application

http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application