简体   繁体   English

如何,或者我可以使用Windows Azure移动服务查询WindowsPhone8应用程序中的多个表?

[英]How, or can i query multiple tables in WindowsPhone8 Application using Windows Azure Mobile Services?

Im using in my wp8 c# application a cloud database trough Azure Mobile Services. 我在我的wp8 c#应用程序中使用Azure移动服务的云数据库。 I have two tables that i connected with each other with foreign keys. 我有两个表,我用外键相互连接。

  1. MovieTable (Id,Title,length,genre) MovieTable(身份证,标题,长度,流派)
  2. EventTable (id,date,movieId) EventTable(id,date,movieId)

In my application i can query them separately like the documentation said: 在我的应用程序中,我可以像文档说的那样单独查询它们:

so i can query my MovieTable like this 所以我可以像这样查询我的MovieTable

private MobileServiceCollection<MovieTable, MovieTable> items;
    private IMobileServiceTable<MovieTable> Mtable = App.MobileService.GetTable<MovieTable>();

then in my method: 然后在我的方法中:

int selectedId= 13;  // its coming from the user interface, not important now

items = await Mtable
             .Where(mov => mov.Id == selectedId )
             .ToCollectionAsync();

             Movietable tb = items[0];
             txtTitle.Text = td.Title;
             txtlength.Text= td.Length; 

So what im looking for is to reach all the data parts of the two table like above 所以我正在寻找的是如上所述到达两个表的所有数据部分

     items = await Mtable,ETable    (E table is for my Event Table)
             .Where(event => event.Id == selectedId && event.Id =Mtable.Id )
             .ToCollectionAsync();

             Eventtable tb = items[0];
             txtTitle.Text = tb.Title;
             txtlength.Text= tb.Length;

and the important 而重要的

             txtDate.Text= tb.date;  

I know its wrong syntax, but its just for demonstrate what im trying to reach. 我知道它的语法错误,但它只是为了展示我想要达到的目的。

in simple sql its looks like 在简单的SQL中它看起来像

 select * 
 from MovieTable m1,EventTable e1
 where m1.id==e1.id

So it is possible somehow through azure mobile service ? 所以有可能通过azure移动服务?

Also i know and i already created view in Azure database management portal, but i dont know how can i reach that view in my application, i cannot found any docs about reaching those views. 我也知道,我已经在Azure数据库管理门户中创建了视图,但我不知道如何在我的应用程序中访问该视图,我找不到任何关于达到这些视图的文档。

How about implementing a custom API for the mobile service? 如何为移动服务实现自定义API? You can do the table join here instead of dragging everything down to the phone... http://blogs.msdn.com/b/carlosfigueira/archive/2013/06/14/custom-apis-in-azure-mobile-services.aspx 您可以在此处加入表格,而不是将所有内容拖到手机上... http://blogs.msdn.com/b/carlosfigueira/archive/2013/06/14/custom-apis-in-azure-mobile- services.aspx

I know this is a little late, but I was having the same problem. 我知道这有点晚了,但我遇到了同样的问题。

You can create a view. 您可以创建一个视图。 I created my view in Visual Studio. 我在Visual Studio中创建了我的视图。 Be sure to use the same schema as the tables you are querying or this won't work. 确保使用与要查询的表相同的模式,否则这将无效。

Then create a new table in azure mobile services with same name. 然后在同名的azure移动服务中创建一个新表。

The table won't actually show anything in azure web portal, but you will be able to query just like any other table through mobile services. 该表实际上不会在azure Web门户中显示任何内容,但您可以通过移动服务查询任何其他表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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