帮助实体框架方法. [英] Help with Entity framework approach.
问题描述
我是实体框架方法的新手,我正在计划在办公室将其用于小型应用程序.
但是,我可以看到EF成为非常好的我们计划在不久的将来在其他一些应用程序中使用这种方法.
某人从Oreilly买了一本书,叫做编程实体框架",但其中有很多错误,因此我无法真正完成这些示例,也无法清楚地了解如何完成以下任务:
我需要编写一个类库来处理所有数据库调用,然后返回结果.我只想将LINQ语句发送给该类,然后将结果返回.
我曾尝试在网上查找示例,但没有找到可以作为示例的内容.
I''m new to the entity framwork approach and im planning on using it for a small application here at the office.
However , I can see EF to become a very good approach in some other applications we are planning on writing in the near future.
A bought a book called "Programming Entity Framework" from Oreilly, but it has so many errors in it so I can''t really do the examples and get a clear understanding on how to accomplish the following:
I need to write a class library to handle all the database calls and then return the results. I just want to send the LINQ statement to the class, and then get the result back.
I have tried to find examples on the net, but I didn''t find anything that I could look at as an example.
任何人都可以给我发送链接或为我提供有关如何处理插入,更新和删除操作的示例.
Can anyone please send me links or give me an example on how to handle this for Inserts, updates and deletes.
推荐答案
在 linq to ef crud 上尝试使用Google搜索.我遇到了很多热门话题,而前几名则看上去似乎与您正在寻找的功能类型有关.
Try Googling on linq to ef crud. I got loads of hits and the top few looked as if they concerned the type of functionality you are looking for.
我将要求您创建类库项目.然后添加ADO.NET实体Model(edmx).然后从Visual Studio屏幕的背面添加(system.Data.Entity/具有实体连接字符串/edmx的一个App Config)
然后作为美国应用程序编程-编写一个使用ObjectContext实例从数据存储区获取数据的方法.
例如...
Hi,
I would request you to create the class library project. Then add the ADO.NET entity Model(edmx).Then from the back of the screen Visual Studio add (system.Data.Entity/One App Config with the Entity Connection String/ edmx )
Then as usaul application programming - Write a method which uses ObjectContext instance to get the data from the datastore.
For instance...
public static Customer GetCustomer(int id)
{
using( NorthWindEntities context = new NorthWindEntities())
{
return context.Customers.Where( c => c.Id == id).FirstOrDefault<customer>();
}
}
</customer>
希望对您有所帮助!.
问候,
-Vinayak
I hope this helps!.
Regards,
-Vinayak
这篇关于帮助实体框架方法.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!