I have a question:
When I create my custom domain service (to consume 3rd party web service) where I use parametrized CRUD methods everything works, except creating a new record.
Lightswitch adds this domain service as a datasource and is able to create a screen for adding new record. When I click the “Save” button in generated application, it correctly calls the Create method on domain service, the record is correctly created by remote web service and the program is leaving the Create method on a domain service. but suddenly the lightswitch calls the default query method, which is non parametrized and returning a IEnumerable in my case.
It seems like Lightswitch is trying to re-read the yet created record to display it. But it does not use a proper ReadOne method, which is correctly prepared, created and even recognized by Lightswitch, because it is able to call it on an other detail screen.
Why does Lightswitch call this [Query(IsDefault=true)] method please?
Thank you for any hints
Gusta Vomacka
The reason LightSwitch requires you to have a default method that takes no parameters is because it threats WCF RIA Services like “database tables” and it will call this method whenever it is trying to show information “in the table”. If you have a filter, it will also attemt to filter the data (for example to get page one it will add “.skip(1).Take(10)” to the call).
You answer may be to not use a WCF RIA Service in this instance.
Use this method:
http://blogs.msdn.com/b/bethmassi/archive/2012/01/30/calling-web-services-to-validate-data-in-visual-studio-lightswitch.aspx