0

我正在使用 odata 库来读取 OData 提要,但 Entry 没有向我显示任何属性。

using (ODataMessageReader messageReader = new ODataMessageReader(message.GetResponse(), new ODataMessageReaderSettings()))
{
    ODataReader reader = messageReader.CreateODataFeedReader();
    while (reader.Read())
        while (reader.Read())
        {
            switch (reader.State)
            {
                case ODataReaderState.EntryStart:
                {
                    ODataEntry entry = (ODataEntry)reader.Item;
                    var atomMetadata = entry.Properties.ToList(); 
                    break;
                }
             }
         }
}

这里var atomMetadata = entry.Properties.ToList();没有返回任何属性。

4

1 回答 1

2

“ODataReaderState.EntryEnd 将返回属性,而不是“ ODataReaderState.EntryStart

using (ODataMessageReader messageReader = new ODataMessageReader(message.GetResponse(), new ODataMessageReaderSettings()))
{
    ODataReader reader = messageReader.CreateODataFeedReader();
    while (reader.Read())
        while (reader.Read())
        {
            switch (reader.State)
            {
                case ODataReaderState.EntryEnd:
                {
                    ODataEntry entry = (ODataEntry)reader.Item;
                    var atomMetadata = entry.Properties.ToList(); 
                    break;
                }
             }
         }
}
于 2013-09-23T11:13:32.987 回答