[英]How to access the Entity Framework
I have mapped the database in the edmx file from the database. 我已经从数据库中将数据库映射到edmx文件中。 Now how do I use linq to make a query?
现在如何使用linq进行查询?
here is an example of my problem 这是我的问题的一个例子
var Found = from o in ??????
What suppose to go in the question marks. 问号中应该包含的内容。 How do I find what suppose to go in the question marks.
如何找到问号中应该包含的内容。 I have tried many tutorials but that do not tell you exactly how to use Linq.
我已经尝试了许多教程,但是并没有确切告诉您如何使用Linq。
Well, Entity Framework generates an ObjectContext for you. 好了,实体框架会为您生成一个ObjectContext。 You should know the name of your ObjectContext class.
您应该知道ObjectContext类的名称。 Then to query using LINQ you can do something line that
然后要使用LINQ进行查询,您可以执行以下操作:
using(var context = new NorthwindContext())
{
var query = from p in context.ProductsSet select p;
// then loop through your query instance.
}
The above example is very simple you should have a look at http://thedatafarm.com/blog/ for better tutorials 上面的示例非常简单,您应该查看http://thedatafarm.com/blog/以获取更好的教程
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.