积极答复者
OData (WCF数据服务) 如何实现多表查询

问题
答案
-
强制转化成LINQ-TO-OBJECT方法,直接用AsEnumerable():
For Account Validation, please follow "Verify Account+Number" at http://social.msdn.microsoft.com/Forums/en-us/home?forum=reportabug
For ASP.NET Question, please ask at http://forums.asp.net
For other questions, you can find a specific forum and then ask at http://stackexchange.com/sites
Click and Donate at http://www.freerice.com- 已标记为答案 server 126 2013年11月13日 11:58
全部回复
-
您好,
OData目前是不知持这种查询方式的。
您可以在服务器端写好像这样的服务,然后直接调用。
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. -
我不太清楚你用的是什么服务。
比如说是WCF Data Service, 你可以在服务器端写好一个方法
public List<T> GetResult() { var client = new OData.Service.TestEntities(ODataUri); var list = from u in client.cdb_user from m in client.cdb_userinfo where u.id == m.user_id select new {m.address,m.zip}; return list; }
在客户端直接接受结果集就可以了。We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. -
强制转化成LINQ-TO-OBJECT方法,直接用AsEnumerable():
For Account Validation, please follow "Verify Account+Number" at http://social.msdn.microsoft.com/Forums/en-us/home?forum=reportabug
For ASP.NET Question, please ask at http://forums.asp.net
For other questions, you can find a specific forum and then ask at http://stackexchange.com/sites
Click and Donate at http://www.freerice.com- 已标记为答案 server 126 2013年11月13日 11:58
-
"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?><error xmlns=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\"><code></code><message xml:lang=\"zh-CN\">处理此请求时出错。</message><innererror><message>准备命令定义时出错。有关详细信息,请参阅内部异常。</message><type>System.Data.EntityCommandCompilationException</type><stacktrace> 在 System.Data.EntityClient.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbCommandTree commandTree)
\n 在 System.Data.EntityClient.EntityProviderServices.CreateCommandDefinition(DbProviderFactory storeProviderFactory, DbCommandTree commandTree)
\n 在 System.Data.EntityClient.EntityProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree)
\n 在 System.Data.Common.DbProviderServices.CreateCommandDefinition(DbCommandTree commandTree)
\n 在 System.Data.Objects.Internal.ObjectQueryExecutionPlan.Prepare(ObjectContext context, DbQueryCommandTree tree, Type elementType, MergeOption mergeOption, Span span, ReadOnlyCollection`1 compiledQueryParameters, AliasGenerator aliasGenerator)
\n 在 System.Data.Objects.EntitySqlQueryState.GetExecutionPlan(Nullable`1 forMergeOption)
\n 在 System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
\n 在 System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
\n 在 System.Data.Objects.ObjectQuery`1.GetEnumeratorInternal()
\n 在 System.Data.Objects.ObjectQuery.System.Collections.IEnumerable.GetEnumerator()
\n 在 System.Data.Services.WebUtil.GetRequestEnumerator(IEnumerable enumerable)
\n 在 System.Data.Services.DataService`1.SerializeResponseBody(RequestDescription description, IDataService dataService, IODataResponseMessage responseMessage)
\n 在 System.Data.Services.DataService`1.HandleNonBatchRequest(RequestDescription description)
\n 在 System.Data.Services.DataService`1.HandleRequest()</stacktrace><internalexception><message>
\nTest.msl(3,4) : 错误 3027: 没有为以下 EntitySet/AssociationSet 指定映射 - cdb_userinfocdb_user。</message><type>System.Data.MappingException</type><stacktrace> 在 System.Data.Mapping.StorageMappingItemCollection.ViewDictionary.SerializedGenerateViews(StorageEntityContainerMapping entityContainerMap, Dictionary`2 resultDictionary)
\n 在 System.Data.Mapping.StorageMappingItemCollection.ViewDictionary.SerializedGetGeneratedViews(EntityContainer container)
\n 在 System.Data.Common.Utils.Memoizer`2.<>c__DisplayClass2.<Evaluate>b__0()
\n 在 System.Data.Common.Utils.Memoizer`2.Result.GetValue()
\n 在 System.Data.Common.Utils.Memoizer`2.Evaluate(TArg arg)
\n 在 System.Data.Mapping.StorageMappingItemCollection.ViewDictionary.GetGeneratedView(EntitySetBase extent, MetadataWorkspace workspace, StorageMappingItemCollection storageMappingItemCollection)
\n 在 System.Data.Metadata.Edm.MetadataWorkspace.GetGeneratedView(EntitySetBase extent)
\n 在 System.Data.Query.PlanCompiler.PreProcessor.ExpandView(Node node, ScanTableOp scanTableOp, IsOfOp& typeFilter)
\n 在 System.Data.Query.PlanCompiler.PreProcessor.ProcessScanTable(Node scanTableNode, ScanTableOp scanTableOp, IsOfOp& typeFilter)
\n 在 System.Data.Query.PlanCompiler.PreProcessor.Visit(ScanTableOp op, Node n)
\n 在 System.Data.Query.InternalTrees.ScanTableOp.Accept[TResultType](BasicOpVisitorOfT`1 v, Node n)
\n 在 System.Data.Query.InternalTrees.BasicOpVisitorOfT`1.VisitNode(Node n)
\n 在 System.Data.Query.PlanCompiler.SubqueryTrackingVisitor.VisitChildren(Node n)
\n 在 System.Data.Query.PlanCompiler.SubqueryTrackingVisitor.VisitRelOpDefault(RelOp op, Node n)
\n 在 System.Data.Query.PlanCompiler.PreProcessor.Visit(ProjectOp op, Node n)
\n 在 System.Data.Query.InternalTrees.ProjectOp.Accept[TResultType](BasicOpVisitorOfT`1 v, Node n)
\n 在 System.Data.Query.InternalTrees.BasicOpVisitorOfT`1.VisitNode(Node n)
\n 在 System.Data.Query.PlanCompiler.SubqueryTrackingVisitor.VisitChildren(Node n)
\n 在 System.Data.Query.InternalTrees.BasicOpVisitorOfNode.VisitDefault(Node n)
\n 在 System.Data.Query.InternalTrees.BasicOpVisitorOfNode.VisitPhysicalOpDefault(PhysicalOp op, Node n)
\n 在 System.Data.Query.InternalTrees.BasicOpVisitorOfT`1.Visit(PhysicalProjectOp op, Node n)
\n 在 System.Data.Query.InternalTrees.PhysicalProjectOp.Accept[TResultType](BasicOpVisitorOfT`1 v, Node n)
\n 在 System.Data.Query.InternalTrees.BasicOpVisitorOfT`1.VisitNode(Node n)
\n 在 System.Data.Query.PlanCompiler.PreProcessor.Process(Dictionary`2& tvfResultKeys)
\n 在 System.Data.Query.PlanCompiler.PreProcessor.Process(PlanCompiler planCompilerState, StructuredTypeInfo& typeInfo, Dictionary`2& tvfResultKeys)
\n 在 System.Data.Query.PlanCompiler.PlanCompiler.Compile(List`1& providerCommands, ColumnMap& resultColumnMap, Int32& columnCount, Set`1& entitySets)
\n 在 System.Data.EntityClient.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbCommandTree commandTree)</stacktrace></internalexception></innererror></error>"