For the complete tutorial directory, see :《CustomData service providers-Introduction"
Whenever I write a plug-in and connect it to the framework system, I always think: How does the framework system call my plug-in?
I am used to this mode of thinking, which simplifies my understanding of how it works.
In factDSPIn the development process, I also use this method to understandDataservice.
I will usePseudoCodeTo describe theseDSPHow the interface is called.
Scenario - Basic Query
Think about it. A client initiatesGetRequest, for example:/Sample. svc/products (1).
FirstData Services.
//Get service provider
VaR dataservice = ...;
Iserviceprovider sp = dataservice as iserviceprovider;
If (sp = NULL)
{
//Add the code here later!!!
}
//ObtainDSPImplementation of each interface
Idataservicemetadataprovider MDP =
Sp. getservice (typeof (idataservicemetadataprovider ));
Idataservicequeryprovider QP =
Sp. getservice (typeof (idataservicequeryprovider ));
//Assign values if necessaryCurrentdatasourceAttribute
If (QP. currentdatasource = NULL)
QP. currentdatasource = dataservice. createdataservice ();
//Try to get the nameProductsResource set
VaR resourceset = NULL;
If (! MDP. tryresolveresourceset ("products", out resourceset ))
Throw new exception ("404 ");
//Obtain a resource setProductsObject (Queryable)
Iqueryable queryroot = QP. getqueryrootforresourceset (resourceset );
//UseURL(For example$ Filter/$ select) Merges existing query objects into new Query expressions.
Queryroot = compose (options, queryroot );
//Write the "Header" part of the reply
Writestartodatafeed ();
//Enumerate all query results
Foreach (Object resource in queryroot)
{
//Obtain the type of the resource.
//The type in the result set may be the derived type of the basic type, resulting in different instance types.
Resourcetype type = QP. getresourcetype (type );
Writeresource (resource, type );
}
Writeendodatafeed ();
I hope this pseudocode can help you understandDSPInData ServiceHow the framework works.
Next step
In the next tutorial, We will temporarily leave this query model and begin to implement service operations and query interceptors.