views:

69

answers:

1

I'm getting started with Astoria/ADO.NET Data Services/WCF Data Services. Looking through a lot of the code samples out there, it appears that the MimeType attribute used to be a method level attribute. After installing the latest update, it is now a class level attribute.

If I have more than one Service Operation that I want to return as a certain MimeType, then it appears now that I have to create a new service for each operation. Is this correct?


Most examples are like this:

[WebGet]
[SingleResult]
[MimeType("application/pdf")]
public IQueryable<byte[]> FooPDF()
{
    var result = from p in this.CurrentDataSource.MyPDFs
                 where p.FooID == 2
                 select p;

    return result.Take(1).Select(p => p.PDF);
}

I get "Attribute 'MimeType' is not valid on this declaration type. It is only valid on 'class' declarations." when I compile, because now I can't do this.


Now, I have to do this:

[MimeType("FooPDF", "application/pdf")]
public class FooService : DataService<FooDBEntities>
{
    public static void InitializeService(DataServiceConfiguration config)
    {
        config.SetServiceOperationAccessRule("FooPDF", ServiceOperationRights.All);
    }

    [WebGet]
    [SingleResult]
    public IQueryable<byte[]> FooPDF()
    {
        var result = from p in this.CurrentDataSource.MyPDFs
                     where p.FooID == 2
                     select p;

        return result.Take(1).Select(p => p.PDF);
    }
}

What's worse is that I can't add duplicate MimeType attributes to my class.

Is all of this really by design, or am I missing something?

+1  A: 

Thanks for reporting this bug to us. I have opened this at our end to track this issue

With the recent update, we added the support for blobs as a first class concept in the data services. If you have a blob association with an entity, then both server and client have ways to surface this. To know more about this, please refer to the following link: http://msdn.microsoft.com/en-us/library/ee473426(v=VS.100).aspx

Hope this helps.

Thanks Pratik [MSFT]

Pratik Patel