WCF Rest/Entity Framework - View Not Deserializing as expected
I have a view that returns data like the following:
开发者_运维技巧1 | Abita | NULL | http://www.abita.com/
2 | Abita | Abbey Ale | http://abita.com/brews/abbey_ale.phpI am using WCF REST to get the xml representation of this view, via an entity framework object. When viewing the returned data as xml in a browser, the first row shows data as I expect:
<vw_Url z:Id="i1" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/">
- <EntityKey z:Id="i2" xmlns="http://schemas.datacontract.org/2004/07/System.Data.Objects.DataClasses" xmlns:a="http://schemas.datacontract.org/2004/07/System.Data">
<a:EntityContainerName>FierceBeersEntities</a:EntityContainerName>
- <a:EntityKeyValues>
- <a:EntityKeyMember>
<a:Key>Brewery</a:Key>
<a:Value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">Abita</a:Value>
</a:EntityKeyMember>
</a:EntityKeyValues>
<a:EntitySetName>vw_Url</a:EntitySetName>
</EntityKey>
<Beer i:nil="true" />
<Brewery>Abita</Brewery>
<RowId>1</RowId>
<Url>http://www.abita.com/</Url>
</vw_Url>
However, the second row doesn't appear to deserialize the row/object correctly, as it doesn't contain the data from row two.
<vw_Url z:Ref="i1" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" />
Any idea why this might be?
UPDATE: I've tracked this down to being caused by a UNION within the view. The rows are unioned together from two different tables, and for some reason, EF is treating the second as a reference to the first. Perhaps this is an EF bug? Any ideas for a workaround?
Sounds like this may be an EF bug/limitation in EF 1.0. http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/9293cf4d-deef-40b1-ab56-a0ee1e770dd9 However, I am using EF 4.0 and it still seems to be an issue. Sigh...
UPDATE: I've tracked this down to being caused by a UNION within the view. The rows are unioned together from two different tables, and for some reason, EF is treating the second as a reference to the first. Perhaps this is an EF bug?
Sounds like this may be an EF bug/limitation in EF 1.0. http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/9293cf4d-deef-40b1-ab56-a0ee1e770dd9 However, I am using EF 4.0 and it still seems to be an issue. Sigh...
精彩评论