简体   繁体   中英

change azure mobile service api controller prefix from api to tables

I am making a mobile service with a .NET backend to host a database for my apps and am trying to switch over from a NodeJS backend to one with the .NET backend. Currently, I am using a webapi controller, as I wanted to implement the repository pattern and ran into some indexing issues when using the table controllers and EntityData as my model base class.

Now, this means that the route to the controllers is "api/controller," but the client side MobileService.GetTable looks for a route with "tables/controller". How can I change my api controller to use the new route? I've found that putting [RoutePrefix("tables/appsetting")] above my AppSettingsController is not accomplishing this purpose.

If you are using a custom controller, then you can use the InvokeAPIAsync method on the client to POST, PUT, GET, or DELETE. You lose some of the built in features of the tables like the filtering, selecting, etc. and would have to build that yourself in the custom API.

The two (table/API) are treated differently and hosted on the backend under that URI space. Even if you got the routes working, the fact that your Custom API controller isn't a table controller means several of the client functions would probably fail unless you somehow implemented them on the custom API controller.

If you need more control over the indexes you can use attributes on your model to create additional indexes including composite and unique indexes: http://msdn.microsoft.com/en-us/data/jj591583.aspx#Index

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM