I have 2 projects:
- WebService - to perform all DAL and BLL functions
- web site - as a front end for this WebService
And some questions:
1. Data types conflict.
WebService has its asmx created by your wizard. It contains a method GetAllOrders that returns ChangeSet::
using Telerik.OpenAccess; |
namespace MyServiceSpace |
{ |
[WebService(Namespace="MyServiceSpace")] |
public class MyServiceClass : System.Web.Services.WebService |
[WebMethod] |
public ObjectContainer.ChangeSet GetAllOrders() |
.... |
In the web site there is a Web Reference to this service - named MyServiceRef. And I try to execute GetAllOrders:
using Telerik.OpenAccess; |
...... |
MyServiceRef.MyServiceClass srv = new MyServiceRef.MyServiceClass(); |
ObjectContainer.ChangeSet res = srv.GetAllOrders(); |
Oops - I get a compiler message: Cannot convert 'MyServiceRef.ChangeSet' to 'Telerik.OpenAccess.ObjectContainer.ChangeSet'
Why? How to avoid it? If I change the type of "res" to "object" it is performed successfully.
2. How to use ObjectProvider's ResultMethod type: Request?
As I understand this method is intended to make ObjectProvider (and ObjectView and RadGrid supplied with it) working with a WebService. So I've written (copying from your demo):
ObjectProvider provider = new ObjectProvider(); |
provider.BaseType = typeof(PersistentClasses.Order); // the definition of PersistentClasses is available in both projects |
provider.RequestName = "MyServiceClass.GetAllOrders"; |
provider.ResultMethod = Telerik.OpenAccess.ObjectProvider.ResultMethodType.Request; |
provider.ResultName = "Orders"; |
provider.ObjectContextProviderTypeName = "???.MyObjectContainerProvider"; // here is the issue - see below |
Telerik.OpenAccess.ObjectView view = new Telerik.OpenAccess.ObjectView(); |
view.ObjectProvider = provider; |
view.RootType = typeof(PersistentObjects.Order); |
My WebService contains MyObjectContainerProvider class that is automatically generated by your tool (I've changed its default name). As I understand it should be possible to use this class, not a provider class defined in the web site project (another way it doesn't make sense to use the web service). But whatever I put instead of "???" I get a message that this provider cannot be found. Is it possible to use this provider from the web service - and how to declare it?
3. Using ObjectContainer - "best practices".
In your demo you use the method described above. But in the sample code from the Code Library (Working with Disconnected API using ObjectContainer) you use just another way. In terms of my example it would be:
MyServiceRef.MyServiceClass srv = new MyServiceRef.MyServiceClass(); |
ObjectContainer container = new ObjectContainer(); |
container.Apply(srv.GetAllOrders()); |
RadGrid1.DataSource = container.Extent(typeof(PersistentClasses.Order)); |
What are the differences between these two methods? What are pros and cons in both cases?
Regards
Tomasz