Ok im abit confused how this works with wcf web services.
I have
Programmes (associated with an ID)
Groups (GroupID)
Tags (TagsID)
Users (UserID)
Now lets say Groups are associated with programmes, tags are also associated with groups and users associated to all of them.
For instance Group CSharp is associated with the Programme Computing and the tags webservice and rest but the rest tag is also associated with the Group asp.net how do I return all groups associated with rest?
I have:
IGroupService
IProgrammeService
ITagService
IUsers
How do I associate them and return users belonging to groups and groups related to tags etc?
Not sure I understand the question. Are you trying to return all of this information in a single call to the service and wondering what the data contract would be for this type of object graph with all of these relations (and most likely circular references)?
I am probably more confused about the question with the latest bits of information but I will take one last stab at this. I guess what is more confusing is the reference to the term "entities". Is this more of an EF question? If linking is an issue with EF I can only assume a code-first approach is being taken. An example of linking Groups to Tags would look something like this.
public class Group
{
public Group()
{
Tags = new List<Tag>();
}
public string Name { get; set; }
public List<Tag> Tags { get; set; }
}
public class Tag
{
public string Name { get; set; }
}
To query for all groups that have a specific tag using Linq you would do something like this:
public List<Group> GetGroups(string TagName)
{
List<Group> groups = (from g in _program.Groups where
(from t in g.Tags where t.Name == TagName select t).Count() > 0
select g).ToList();
return groups;
}
If you are using SOAP you would create a proxy in your client and calling the service would look like this:
string tagName = "rest";
List<Group> groups = proxy.GetGroups(tagName);
If you are creating a REST API then it would be a simple HTTP request:
http://server/api/GetGroups?tagName=rest
Where the service would return you either XML or JSON representing the Groups.
You list a number of interfaces which I assume contain the operations and data contracts for your services. You do not necessarily need to break your service up by entities and it may also be confusing as to where to put certain operations and data contracts. If a service returns information for multiple entities you will need to repeat data contracts across your service. Breaking service up by entities will not provide much benefit and only make it more difficult for you and any users of the service.
public void AddTagstoGroup (Group group, Tag tag)
Garrith Graham 2012-04-06 19:07