导航属性不会正确地为查找公开Id [英] Navigation Properties don't expose Id correctly for lookups
问题描述
看起来外键从主表暴露到查找表不会将引用键暴露给查找表。而是链接从主表引用实体并强制客户端通过URL进行查找。
It appears the exposure of foreign keys from a main table to a lookup table does not expose the referencing key to the lookup table. Rather the link references the entity from the main table and forces the client to lookup via a URL.
通过使用展开,我可以将数据通过,但它非常冗长并且使消息膨胀。我们有10-15个查找字段的主表。因此,我必须扩展每个字段以获取引用的ID。
By using expand I can bring the data through but it is extremely verbose and bloats the message. We have main tables with 10-15 lookup fields. So, I would have to expand every field to just get the referenced Ids.
此设计可以防止客户端缓存查找表,只使用id引用它们。
This design prevents a client from caching lookup tables and just using the id to reference into them.
我能找到的唯一解决方法是创建一个视图并手动修改edmx文件以解决EntityKey错误,其中将视图拉入EDM会创建许多EntityKeys。然后,一旦完成,客户端仍然无法理解这些关系。
The only workaround I can find is to create a view and hand modify the edmx file to workaround the EntityKey bug where pulling a view into EDM creates many EntityKeys. Then, once this is done the client will still not understand the relationships.
这里的模型似乎已被打破。我认为需要有一个中间立场,允许relationaship在主实体中作为引用查找实体的链接。
The model seems broken here. I think there needs to be a middle ground that allows the relationaship to come through in the main entity as a link that references the lookup entity.
所以,今天它看起来像这样:
So, today it looks like this:
- < 条目 > |
< id > http:// localhost:1606 / Tracetastic.svc / trace(guid'd397ffda-58a3-4e92-b607-0035b6322046') < / id > |
< link rel = " edit" title = " trace" href = " trace(guid'd397ffda-58a3-4e92-b607-0035b6322046')" /> |
< link rel = " http://schemas.microsoft.com/ado/2007/08/dataservices/related/application" type = " application / atom + xml; type = entry" ; title = " application" href 字体> < font style ="font-size:11px"> = " trace(guid'd397ffda-58a3-4e92-b607-0035b6322046')/ application" /> |
< 内容 类型 = " application / xml" > |
- < m:properties > |
< d:id m: type = " Edm.Guid" > d397ffda-58a3-4e92-b607-0035b6322046 < / d:id > |
< d:message_text > ; 收到的WCF请求net.tcp上的消息:// localhost:7766 / FrameworkTests / 1.0 / ChannelTest < / d:message_text > |
< d:process_number m: type = " Edm.Int16" > 8888 < / d:process_number > |
< d:application_domain_number m: type = " Edm.Int16" > 3 < / d:application_domain_number > |
< / m:properties > |
< / / font> content > |
< / 条目 > |
- <entry> |
<id>http://localhost:1606/Tracetastic.svc/trace(guid'd397ffda-58a3-4e92-b607-0035b6322046')</id> |
<link rel="edit" title="trace" href="trace(guid'd397ffda-58a3-4e92-b607-0035b6322046')" /> |
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/application" type="application/atom+xml;type=entry" title="application" href="trace(guid'd397ffda-58a3-4e92-b607-0035b6322046')/application" /> |
<content type="application/xml"> |
- <m:properties> |
<d:id m:type="Edm.Guid">d397ffda-58a3-4e92-b607-0035b6322046</d:id> |
<d:message_text>Received WCF Request message on net.tcp://localhost:7766/FrameworkTests/1.0/ChannelTest</d:message_text> |
<d:process_number m:type="Edm.Int16">8888</d:process_number> |
<d:application_domain_number m:type="Edm.Int16">3</d:application_domain_number> |
</m:properties> |
</content> |
</entry> |
这篇关于导航属性不会正确地为查找公开Id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!