I let the WAMS wizard create the “test” table (“Elements”), which he suggests creating after setting up my WAMS.
Then I wanted to create a table that would really be useful to me. The wizard's instructions say: "You can add and delete tables later using the Data tab above."
So, I did this, and I created the table, but now I do not see where I can change the structure of the table (IOW, add columns). I tried double-clicking the link, 2 clicking on the table, selecting the "Create" button, right-clicking on the name of a single column (id) in my table, etc., but all to no avail.
Something that I am also embarrassed about is the relationship of the tables that I create in this way with my existing SQL DB tables - or can I do without this SQL database (as soon as I get these WAMSical tables)?
Or why can't I link existing SQL DB tables to my WAMS? And if I can - how?
UPDATE
In addition, it seems that there is a discrepancy between what is written and what I actually experience. This (from http://msdn.microsoft.com/en-us/magazine/jj721590.aspx ) is wrong / did not happen for me:
"2.Create a relational table to store your data. When you click the Create TodoItem table button, the wizard will automatically create a table based on the Windows Azure SQL database that you created (or reused) earlier."
I tried it from scratch, creating a new WAMS. Again, I get when I select an existing SQL database, "Database and mobile service are not in the same region." Productivity will decrease ... In addition, data sent from the database to the mobile service will be considered paid bandwidth. we recommend that you select the database in the same location as the mobile service. "
I would like to, but how? Why didn't WAMS automatically change this for me - or at least give me the opportunity to place my database and mobile service in one place?
UPDATE 2
Interestingly, I can see new tables in LINQPad. I already had two SQL DB tables that appear under this connection information, but at the same level as these tables, this is my WAMS name, under which are the "Default" Items table and I created one of my own (both of which, only one column, in particular "Id (Int64)"
IOW what I see in LINQPad:
blaBlaBla.database.windows.net,1433.blaBla BlaBla BlaBlaSQLDB_Table1 BlaBlaSQLDB_Table2 wamsName Items Id (Int64) BlaBlaWAMSTable Id (Int64)
... since I am expanding / managing "BlaBlaWAMSTable" - the problem is now ...
UPDATE 3
Well, you look here; LINQPad to the rescue again:
select * from <WAMSName>.<TableName>
... shows that there is a record after I created the table I wanted through the class in my project (NOT in the Azure / WAMS management area).
... and of course LINQPad shows the added added columns in this way.
All I needed to do was follow the steps below (link to the Azure SDK, add an appropriate usage suggestion, etc.) and then add this method to verify it:
private async void InsertTestRecordIntoWAMSSQLDBTable() { <WAMS Table class name> invitation = new <WAMS Table class name> { SenderID = " donkeyKongSioux@supermax.gov ", ReaderDeviceID = "00-AA-11-BB-01-AB-10-BA", ReaderName = "B. Clay Shannon", SenderUTCOffset = 5, SenderDeviceID = "BA-10-AB-01-BB-11-AA-00" }; await App.MobileService.GetTable<<WAMS Table class name>>().InsertAsync(invitation); }
... and it worked. Now it would be nice to have some examples / examples for selected queries as well as updates.
And my big remaining question (so far) is: can I decorate / annotate the columns / members of my table class? IOW, can I change this:
public class {public int Id {get; set; } public string SenderID {get; set; } public string ReaderDeviceID {get; set; } public string ReaderName {get; set; } public int SenderUTCOffset {get; set; } public string SenderDeviceID {get; set; }}
... something like that:
public class {[Primary, AutoInc] public int Id {get; set; } [Indexed] public string SenderID {get; set; } [Unique] public string ReaderDeviceID {get; set; } [MaxLength (255)] public string ReaderName {get; set; } public int SenderUTCOffset {get; set; } public string SenderDeviceID {get; set; }}
?
I cannot do just that, since these are SQLite annotations, but since I cannot manage my table from the Azure / WAMS portal, how can I label these attributes?
After changing the design of the table in the code, I can see that these columns were added to my table in the WAMS portal, but it seems that the only thing I can do for the columns is to add an index ...
UPDATE 4
It turns out that creating tables in WAMS is as simple as pie (but not as simple as pi / as hard as pi) - as soon as you know how to do it.
With WAMS created, select "Data" and then "Create" to create the table. Give it a name and select the permissions you want. This will give you a deadly dull but “live” database table with one, number, one, column: ID, BigInt, indexed.
THEN, to actually add more columns to the table, the easiest way I found (the only way I found, and this is easy):
1) Create a class corresponding to the database table, a la SQLite, for example:
public class WAMS_DUCKBILL { public int Id { get; set; } public string PlatypusID { get; set; } public DateTime UpdateTimeUTC { get; set; } public double Income { get; set; } public double Outgo { get; set; } }
2) Write a method that will add an entry to this table, for example:
private async void InsertTestRecordIntoWAMSDuckbillTable() { WAMS_DUCKBILL duckbill = new WAMS_DUCKBILL { PlatypusID = "42", UpdateTimeUTC = DateTime.Now, Income = 3.85, Outgo = 8311.79 }; await MobileService.GetTable<WAMS_DUCKBILL>().InsertAsync(duckbill); }
3) Call this method from App.xaml.cs' OnLaunched event
4) As you can see, by executing the following query in LINQPad (or, nevertheless, you want to view [k, r] in the database):
SELECT * FROM platypi.WAMS_DUCKBILL
Call me old fashioned, but notice that I'm using tired old SQL, not LINQ here; so judge me. In any case, LINQPad shows that the test record was indeed inserted into the WAMS table. Voila! as cats that eat around their neck say on racist cats.