1

DataServiceConfiguration.MaxResultsPerCollectionieに設定し2た場合、結果が大きくなると<m:error>タグがありますが、結果の XML ファイルは無効です (終了がありませ<feed>ん)。なんで?それは期待されていますか?それを(適切に)どのように解析できますか?

例:

public class WcfDataService1 : DataService<DummyContext>
{
    public static void InitializeService(DataServiceConfiguration config)
    {
        config.SetEntitySetAccessRule("*", EntitySetRights.All);
        config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;

        config.MaxResultsPerCollection = 2;
    }
}

public class DummyContext
{
    public IQueryable<DummyClass> Data
    {
        get
        {
            return Enumerable.Range(1, 10).Select(x => new DummyClass() { Id = x, FooBar = x * 2 }).AsQueryable();
        }
    }
}

[DataServiceKey("Id")]
public class DummyClass
{
    public int Id { get; set; }
    public int FooBar { get; set; }
}

結果:

<?xml version="1.0" encoding="utf-8"?>
<feed xml:base="http://localhost:49627/WcfDataService1.svc/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
    <id>http://localhost:49627/WcfDataService1.svc/Data</id>
    <title type="text">Data</title>
    <updated>2012-10-31T11:43:03Z</updated>
    <link rel="self" title="Data" href="Data" />
    <entry>
        <id>http://localhost:49627/WcfDataService1.svc/Data(1)</id>
        <category term="WebApplication1.DummyClass" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
        <link rel="edit" title="DummyClass" href="Data(1)" />
        <title />
        <updated>2012-10-31T11:43:03Z</updated>
        <author>
            <name />
        </author>
        <content type="application/xml">
            <m:properties>
                <d:Id m:type="Edm.Int32">1</d:Id>
                <d:FooBar m:type="Edm.Int32">2</d:FooBar>
            </m:properties>
        </content>
    </entry>
    <entry>
        <id>http://localhost:49627/WcfDataService1.svc/Data(2)</id>
        <category term="WebApplication1.DummyClass" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
        <link rel="edit" title="DummyClass" href="Data(2)" />
        <title />
        <updated>2012-10-31T11:43:03Z</updated>
        <author>
            <name />
        </author>
        <content type="application/xml">
            <m:properties>
                <d:Id m:type="Edm.Int32">2</d:Id>
                <d:FooBar m:type="Edm.Int32">4</d:FooBar>
            </m:properties>
        </content>
    </entry>
    <m:error>
        <m:code />
        <m:message xml:lang="cs-CZ">The response exceeds the maximum 2 results per collection.</m:message>
    </m:error>
4

0 に答える 0