Hi,
I've got a stored procedure in my MSSQL database which requires a single parameter. From what I see the VS wizards generates a correct description of the result set and some 4 function are also created. XAF creates all kinds of list-/detail etc. view like I hoped.
There is just a small problem left: how/where do I pass the parameter in XAF?
regards,
Martin
We have closed this ticket because another page addresses its subject:
How to show stored procedure's results in a ListView from navigation
Hello Martin,
Thank you for your question. I guess that this greatly depends on your real scenario. Could you please elaborate more on how you would like to use stored procedures in XAF? Then, I will be glad to tell you how to plug this into your XAF application.
Please provide us with your sample if it additionally clarifies your scenario.
Thanks,
Dennis
Ok,
Let's assume I have a procedure that returns a list of products belonging to a certain category. So 'Fruit' as category returns apples etc. when the category parameter is empty it returns nothing.
The XPO/XAF generates a correct NonPersistent Class and some (4) helper functions.
What do i want:
- the user chooses the listview, it is presented with no data
- he/she chooses a category from a dropdown box
- the list gets filled with the correct products
- he/she changes the category and the list gets refreshed
So far I can see two problems: how to get a dropdown combobox on the listview screen and (the subject of this mail) how to get the list populated with the correct data?
regards,
Martin
This is what I tried using a viewcontroller:
private void ToevoegenBA_Activated(object sender, EventArgs e)
{
ObjectSpace objectSpace = (ObjectSpace)View.ObjectSpace;
XPDataView myview = new XPDataView();
BAK2010SprocHelper.Execprc_not_in_belactieIntoDataView(myview, objectSpace.Session, 3);
((ListView)View).Editor.DataSource= myview;
int dummy = 1;
}
it runs without errors but I do not see any data appear in the listview I target (there are records in the myview.).
regards,
Martin
Hello Martin,
Thank you for the update.
You can use a regular SingleChoiceAction to present a drop down with choices to your end-users. To get a result from a stored procedure, implement a custom CollectionSource class, and then plug it in for the required ListView.
You can use the CollectionSourceBase.Reload method to refresh this ListView when needed. So, I am afraid your last approach is incorrect. Normally, you should never change the data source of a ListEditor, because you may break a lot of functionality.
Instead, refer to the How to populate the list view with data from a LINQ query KB Article, providing more information on how to implement a custom CollectionSource. You may also find the How to display audit info for deleted objects. example helpful.
I look forward to your feedback.
Thanks,
Dennis
Dennis,
Thanks for the update but I think you over-estimate my capacities. Maybe in a few months.
regards,
Martin
Martin, could you please clarify exactly what you mean?
Thanks,
Dennis
I need to have some more experience with XAF to get this going, no problem.
regards,
Martin
OK, thank you for the clarification. Do not hesitate to contact us in case of any difficulties.
Regards,
Dennis