G Gr
G Gr

Reputation: 6080

webservice retrieval methods

I have only ever dealt with database querys before in the old fashion that you could do something like this:

SELECT column_name(s)
FROM table_name1
LEFT JOIN table_name2
ON table_name1.column_name=table_name2.column_name

But over the last few weeks I have been learning about webservices specifically wcf and exposing wcf as restful. What I am wondering tho is if you take something like this:

public class Student
{
    /**
     * Student matriculation number
     */
    [DataMember(Name = "matric")]
    public string Matric;
    /**
     * First name of the student
     */
    [DataMember(Name = "firstname")]
    public string FirstName;
    /**
     * Last name of the student
     */
    [DataMember(Name = "lastname")]
    public string LastName;
    /**
     * The programme that the student is on
     */
    [DataMember(Name = "programme")]
    public string Programme;
}

If I had another service which was say Groups in which each student could belong to a group and I could search specifically for a student belonging to a group how would it be done when storing with xml?

Does anyone know of a good tutorial or an example of the above in which you can join two types of datamembers or contracts?

Upvotes: 1

Views: 87

Answers (1)

Lubomir Velkov
Lubomir Velkov

Reputation: 56

The RESTful service approach is not really connected with the way you join tables in SQL. Basically you have 4 CRUD operations - create, retrieve, update and delete. And each of these operations correspond to an HTTP protocol verb. I think they are -

GET - SELECT POST - UPDATE PUT - INSERT DELETE - DELETE

So depending on your operation you call the WCF service via the specific HTTP verb, by passing arguments in the query string. E.g. if you want to delete a record with ID = 5 you can execute the following HTTP request

DELETE /ServiceName.svc/Records/5

What you actually need in your case is map the database columns to business objects via an ORM software - for example Microsoft Entity Framework. I would suggest you starting here - http://msdn.microsoft.com/en-us/library/bb386876.aspx

Upvotes: 1

Related Questions