实体框架可以进行查询。 [英] Entity Framework can do query.

查看:70
本文介绍了实体框架可以进行查询。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了实体,看起来我有所有的参考资料。但是我无法运行简单的查询。例如,auto complete将无法识别此情况。



I have entity installed and looks like I have all the references. However I can't run a simple query. For example auto complete will not recognize this.

Dim e As WebEntities = New WebEntities()
Dim p As VOD = New VOD()

' Verify if the record already exist
Dim query = From o In e.VOD Where o.Member_ID '<- o.Member_ID this is what I need but when I type in o. there is no auto complete





我错过了参考吗?请帮忙。



Am I missing a reference? Please help.

推荐答案

请先阅读我对这个问题的评论。



它可能是一个错误或它确实缺少参考。



http://connect.microsoft.com/VisualStudio/feedback/details/733278/intellisense-autocomplete-bug-in-vb-multiline-linq-query [ ^ ]

http: //stackoverflow.com/questions/13580326/intellisense-stopped-working-for-linq-to-entities [ ^ ]



我建议阅读这篇文章: LINQ to Entities [ ^ ]以及所有相关文章。



我想你需要参考集库:

Please, read my comments to the question first.

It could be a bug or it's really reference missing.

http://connect.microsoft.com/VisualStudio/feedback/details/733278/intellisense-autocomplete-bug-in-vb-multiline-linq-query[^]
http://stackoverflow.com/questions/13580326/intellisense-stopped-working-for-linq-to-entities[^]

I would suggest to read this article: LINQ to Entities[^] and all related articles.

I guess you need reference set of libraries:



Imports System
Imports System.Data
Imports System.Collections.Generic
Imports System.Linq
Imports System.Data.Linq
Imports System.Xml.Linq
Imports System.Data.Objects
Imports System.Data.EntityClient




using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Data.Linq;
using System.Xml.Linq;
using System.Data.Objects;
using System.Data.EntityClient;








如果类型< type>的表达式是不可用的错误,请参阅: http://msdn.microsoft.com/ en-us / library / bb763092.aspx [ ^ ]

你应该第一次提供这个错误。



In case of Expression of type <type> is not querable error, see: http://msdn.microsoft.com/en-us/library/bb763092.aspx[^]
You should provide this error for the first time.


一些事情。首先,我不知道你为什么要创建一个VOD实例。从您的查询中,您无论如何都不会使用它。



但是,VOD告诉我你正试图查询错误的东西。 />


您的WebEntities(上下文)是否有一个名为VOD的DbSet?我认为不是。我认为它可能更像是 WebEntities.VODs ,这就是你应该查询的内容。

A couple things. First, I don't know why you created an instance of VOD. From your query, you're not going to be using it anyway.

But, that VOD tells me that you're trying to query the wrong thing.

Does your WebEntities (context) have a DbSet called VOD?? I think it doesn't. I think it might be more like WebEntities.VODs and that's what you should be querying on.
Dim query = From o In WebEntities.VODs Where o.Member_ID = ...



但是,由于我们对您的上下文和实体设置一无所知,所有这些只是一个有根据的猜测。


But, since we know nothing about your context and entities setup, all of this is just an educated guess.


*如果VOD是WebEntities模型中的实体。

*试试这段代码并告诉我发生了什么



*If "VOD" is an entity in "WebEntities" model.
*Try this code and tell me what happen

Dim e As WebEntities = New WebEntities()
Dim p As VOD = New VOD()
 
' Verify if the record already exist
Dim query = From o In WebEntities.VOD Where o.Member_ID '<- o.Member_ID this is what I need but when I type in o. there is no auto complete





你可以使用Single 方法返回一个实例。


这篇关于实体框架可以进行查询。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆