如下图实体框架所示,我有 3 个表:tblModel、tblModelFetish 和 tblFetish。 tblModel 中的一条记录可以在 tblModelFetish 表中拥有由 modelid 列链接的多条记录。 tblModelFetish 表通过 fetishID 列链接到 tblFetish 表,以获取存储在 fetish 列中的恋物癖描述。该实体模型是使用 VS 2010 从包含外键的现有数据库生成的。
实体数据模型 http://spreadthenudes.com/efmodel.jpg
使用 odata 语法,我'我能够访问所有模型(http://localhost:51157/WcfDataService.svc/tblModels)或特定模型 (http://localhost:51157/WcfDataService.svc/tblModels(11))成功。我在通过 odata 访问相关表数据时遇到问题,我尝试了很多排列,包括展开等。
我想要的是 tblModel 中所有列和相关 tblFetish 记录(包括 tblFetish 表中的 fetish 列)的结果集。换句话说,Mary(tableModel 中的模型名称)有 3 个恋物癖(tblModelFetish 中的 3 条记录),名为 beach、travel 和 Coffee(存储在 tblFetish、fetish 列中)。
获取此数据的 odata 语法是什么?
感谢您的阅读!鲍勃
As indicated in the Entity Framework image below, I have 3 tables, tblModel, tblModelFetish and tblFetish. A record in tblModel can have multiple records in the tblModelFetish table linked by the modelid column. The tblModelFetish table links to the tblFetish table via the fetishID column to get the fetish description stored in the fetish column. This Entity Model was generated with VS 2010 from an existing database including foreign keys.
a Entity Data Model http://spreadthenudes.com/efmodel.jpg
Using the odata syntax, I'm able to access all models (http://localhost:51157/WcfDataService.svc/tblModels) or a specific model (http://localhost:51157/WcfDataService.svc/tblModels(11)) successfully. I'm having trouble accessing the related tables data via odata, I've tried many permutations including expand etc.
What I want is a result set of all the columns in the tblModel and the related tblFetish records including the fetish column from the tblFetish table. In other words, Mary (a modelname in tableModel) has 3 fetishes (3 records in tblModelFetish) named beach, travel and coffee (stored in tblFetish, fetish column).
What is the odata syntax to acquire this?
thanks for reading! Bob
发布评论
评论(1)
尝试以下任一方法:
或
只是为了明确起见,您不会获得包含所有列的庞大结果集,但实体图由您的实体组成。
Try either:
or
Just to make it clear you will not get one huge result set with all columns but the entity graph consisted of your entities.