开发者

Custom Logic and Proxy Classes in ADO.NET Data Services

开发者 https://www.devze.com 2022-12-28 21:20 出处:网络
I\'ve just read \"Injecting Custom Logic in ADO.NET Data Services\" and my next question is, How do you get your [WebGet] method to show up in the client-side proxy classes? Sure, I can call this dire

I've just read "Injecting Custom Logic in ADO.NET Data Services" and my next question is, How do you get your [WebGet] method to show up in the client-side proxy classes? Sure, I can call this directly (RESTfully) with, say, WebClient but I thought the strong typing features in ADO.NET Data Services would "hide" this from me auto-magically.

So here we have:

public class MyService : DataService<MyDataSource>
{
    // This method is called only once to initialize service-wide policies.
    public static void InitializeService(IDataServiceConfiguration config)
    {
        config.SetEntitySetAccessRule("Customers", EntitySetRights.AllRead);
        config.SetServiceOperationAccessRule("CustomersI开发者_运维知识库nCity", ServiceOperationRights.All);
    }

    [WebGet]
    public IQueryable<MyDataSource.Customers> CustomersInCity(string city)
    {
        return from c in this.CurrentDataSource.Customers
               where c.City == city
               select c;
    } 

}

How can I get CustomersInCity() to show up in my client-side class defintions?


When you see your Odata in browser, you will see link ... e.g. http://localhost:1234/odataService.svc

just write your method name after the link for your method it will be something like this...

http://localhost:1234/odataService.svc/CustomersInCity?city="London"

0

精彩评论

暂无评论...
验证码 换一张
取 消