Azure Mobile App and navigation properties - azure-mobile-services

I'm using an Azure Mobile App for a Xamarin Forms application and wondering if it is possible load navigation properties of an entity when getting it from the db?
Here is a code example:
"var menuItems = await client.GetTable'<'MenuItem'>'().ReadAsync();"
menuItem has a navigation property called comments. In postman I can load these by adding a parameter of $expand=comments on the end of my query string, I'm stuck on how to add this to the code in my app.

Answer #1: Use an [ExpandProperty] to automatically set $expand on the query. See chapter 3 of the Zumo Book at http://aka.ms/zumobook
Answer #2: You don't want to do this (HONEST!) It destroys any data normalization that you are trying to do.

Related

Flutter Mobx - Passing store state between pages in PageView

How can i pass or preserve the state of my store between pages using PageView?
By example, I'm trying to upload an image at the first page to edit, and pass to a second page where i want to show the image with a form. Im using MVC, and the image is set via controller (store), but it's not working. I've been made some tests and sometimes, at debugging runtime, the image is shown at the second page. But, sometimes even debugging it isn't shown and its value is null.
I tried with AutomaticKeepAliveClientMixin also, but the behavior is the same.
Someone can tell me what i'm doing wrong or what i'm missing?
I think using singleton can solve your problem, actually I think I had this problem in two apps I made.
I used get_it plugin, this package creates singletons easily for you and it's simple to retrieve anywhere in the app without using context.
First, register your MobX as Singleton, I do it on main:
getIt.I.registerSingleton<YourStore>(YourStore());
Retrieve the same instance of your Store, if you have observables in the first page and call an action on the second page, it will trigger the observables in the first page or wherever you used any observable from this instance of Store.
GetIt.I<YourStore>().changeImageFromFirstPage();
You can call GetIt.I().youraction() anywhere in your app, it will trigger the observables you created on this Store.
final list = Provider.of<TodoList>(context);
in the MobX document, there is a provider that can be used as the above code.
I use GetIt too, it is really awesome.
there is a sample for this in the following URL for the MobX:
https://mobx.netlify.app/examples/todos

How to implement cross app navigation and navigating back to the Fiori launchpad home?

In our company, we've set up the Fiori launchpad. In it, we have configured a tile that is linked to a custom developed SAPUI5 app, which is deployed as a BSP on the server. It took us a long while, yet using the router pattern within that application, we managed to make the navigation from the launchpad tile to the custom UI5 application work.
The thing we are struggling with, however, are these 2 other navigation paths:
From the application back to the Fiori launchpad (back home)
From the application to another application (tile to tile)
Ideally, this out of application navigation is in the UI5 way, including a transition, so not just a window.replace in JS. After a long search, the only hint I've found in support for this scenario is in this class:
https://ui5.sap.com/#/api/sap.ushell.services.CrossApplicationNavigation
However, I don't understand how to use it. The example isn't even correct and has syntax errors. I've found two forum posts elsewhere asking about how to use it, but they lack any meaningful answer.
Assuming you are using Semantic Objects for in-place navigation configured in your Launchpad to navigate to UI5 Applications you can navigate from one Application to another using the CrossApplicationNavigation service you already mentioned. However, the documentation about it is slightly confusing. This is how it works for me:
// Step 1: Get Service for app to app navigation
var navigationService = sap.ushell.Container.getService("CrossApplicationNavigation");
// Step 2: Navigate using your semantic object
navigationService.toExternal({
target : { semanticObject : "<YourObject>", action: "<YourAction>" },
params : { A : "B" } // optionally
})
If you want to go back to your launchpad after in-place navigation you simply need to call
window.history.go(-1)
This still triggers the correct transition.

MVC Default Edit View increments the id property of my model? Can't figure out why. .

I'm trying to learn web development, and I bet that this is a simple problem and that I'm overlooking something obvious.
In my default crud edit controller (generated using the MVC framework) I retrieve my model from a localDB instance using my EntityFramework's dbContext. That is sent to the View. In the debugger just before the controller call to return View(model) I can see that the Id is set to 2.
When the [post] edit controller is fired I see that the identity property is 3. I wanted to figure out why so I changed the View to display my Id property and I see that it is 3 as soon as I render the page. Last time I saw it the property was 2, now it is 3.
I don't know how to hook into any logic that would happen between the time I send off my model and when when the view is rendered.
Can anyone help me learn how to debug this so that I can figure out why my Id property is incremented when I pass the model into the view?
I don't know how EntityFramework works but I have worked with CakePHP. My advice is like this:
Usually PHP frameworks have debug mode which you can set in the configuration file (turn it on or off). Usually stack of operation executed is also displayed in debug mode or there is a simple way to do that. There's also for example in CakePHP exist function debug($yourVariable); try to search for sth. similar
It seams like not the edit happens but new row is inserted to the database. Check your database for this. I recommend to debug the id of the column being passed for edit action and check if there's the same id in the database first of all.
Hope something helps.
I figured it out. Posting here for anyone else that comes across my problem.
I tried dumping the whole model out without using any of the htmlhelper methods. (In my case I am uinging: Html.HiddenFor helper) When I did this I saw that the value in the model was what I expected it to be. So I began investigating why the helper methods might be broken. Google worked for me here :)
Turns out, when the helper methods run they first check the ModelState dictionary for the desired value. In my case I was looking for a value that was in my model object as well as the ModelState dictionary, because the name was very common: Id.
To fix the issue before I call return View(model) I call ModelState.Clear() in order to make sure there are no values in the dictionary that are in conflict. Doing this causes my page to be rendered correctly.

Error in SAPUI5 routing / binding with 1.18 SDK example: SplitApp

When testing the SplitApp demo app provided with the 1.18.5 SAPUI5 SDK there seems to be a conflict between the routing and model binding. If you navigate to a detail page and then refresh the browser window the data binding fails. This would be the same as if you bookmarked the app on a specific view.
Just wondering if anyone knows why this is? Is it a conflict with routing and data binding? My debugging is not showing anything up yet only that the model is empty when the detail view loads.
This app uses the new Component-based router where you define your routes in the component metadata.
I've also written a small test app here js1972/test · GitHub (branch "routes") which does similar and has the same issue.
the following bookmark works with the fake service
../test-routes/#/detail/Categories(2)
../test-routes/#/detail/Categories(3)
doesnt
request.onSend in ODataModelFakeService.js doesnt cater for all scenarios
an alternative maybe to use sap.ui.core.util.MockServer with a cutdown metadata.xml and json files for the Category and Product entities
I've ran into the same issue and just want to share my findings and solution:
The detail view waits until the list in the master view is loaded. If the service you are using is quite slow the list has already finsihed loading, but the model has not finished loading and thus the detail view returns an error.
To fix this I've attached an "requestCompleted"-event to the model and created a jQuery.Deferred object for the model.
The master then waits for the resolve of the model.
oModel.attachEvent("requestCompleted",
function() {
this.oModelFinishedDeferred.resolve();
this.getEventBus().publish("Model",
"ModelFinished");}
, this);

Stopping Ember.js Controller

My question is very basic on one hand but on the other hand the general situation is more complex, plus I cannot really get any working sample.
I'm developing/maintaing a web-application which is currently in transition from GWT code base into Ember.js.
Most of the newer code already relies on Ember.js and I think it's really awesome.
The problem is we cannot use Ember Router as all the request are being handled by the GWT.
In order to enabled the application run in this unusual configuration we have special JavaScript files that create our Ember main objects (Controllers & Models) for us.
As you can imagine navigation between tabs is cumbersome and is handled by GWT who creates Ember objects when needed. We are in transit toward a brave new world Ember Router and all.
But in the meantime, this is the problem I'm facing right now.
The user clicks a link which opens a page that contains some Ember based table.
The data is retrieved form the server using some Ajax code. Upon success it spawns a forEach loop which tries to pushObject all the received date into our Ember based components.
My problem happens when the user quickly switches between tabs. In this case the first list of object has not finished rendering yet and suddenly there's a new set of objects to handle. This causes Ember to throw errors like:
"Uncaught Error: Cannot perform operations on a Metamorph that is not in the DOM. "
and
"Uncaught NotFoundError: An attempt was made to reference a Node in a context where it does not exist."
Is it possible to prevent the loop from trying to render?
I've tried checking if the controller in question is already inDOM and it is, is there a way to notify Ember this object is no longer valid?
Sorry for a lengthy question and lack of running sample.
I'd probably modify the switch tab code to only execute afterRender has completed, that way you aren't mucking with ember objects while they are being used.
Ember.run.scheduleOnce('afterRender', this, function(){
// call GWT switch tab routine
});
Thank you Daniel and Márcio Rodrigues Correa Júnior. eventually what I did is to add a patch that would check the current context of the application (in my case the currently selected tab). If upon receiving the AJAX response the application is in the correct context (meaning the user haven't change the tab) go on. Otherwise just ignore the response and do not try to render it.
Now it seems to be working