This is a WCF project. The idea is to use this WCF Service as a "go-between" between my ASP.NET site and SharePoint. This way I avoid CAML in the ASP.NET site and it keeps all of the code that accesses SharePoint encapsulated inside the WCF Service. Ideally I would like this WCF service to be a .NET 4.0 project but I'm not sure if that is possible at this stage either, however if I don't directly connect to the SharePoint Object model and use OpenWeb then I think I should be OK? Any feedback on this would be great too.
I have a situation where I want to "dynamically connect" to one of any Service References in my WCF Service code. The Service References are connecting to the _vti_bin/ListData.svc that all have identical structures (A, B and C as shown below...) so all Lists and Columns are all named the very same across multiple Site collections. The structure is like this.
Root Level Site
1. ASite
2. BSite
3. CSite
4. ...and more to follow.
1-4... are all Site Collections using their own Content Databases.
I have manually created the Service References and then I write the code as show below to connect in to do what I need to do with the Lists etc.
My dilemma is that I dont know how to dynamically connect to any given Reference rather than writting code for each Reference. Because each reference has it's own named DataContext I dont even know if this is possible.
FYI the spSite string is something like http://sps.mysite.com/sites/asite/_vti_bin/ListData.svc and http://sps.mysite.com/sites/bsite/_vti_bin/ListData.svc ....
var serviceReferenceASite =
new ServiceReferenceASite.ASiteDataContext(
new Uri(spSite)) { Credentials = Utilities.GetCredentials() };
IEnumerable<ServiceReferenceASite.JobNumbersItem> jobList =
from jobNumbers in serviceReferenceASite.JobNumbers
where !jobNumbers.JobStatus.Title.Contains("Job Complete")
orderby jobNumbers.JobNumber
select jobNumbers;
var serviceReferenceBSite =
new ServiceReferenceBSite.BSiteDataContext(
new Uri(spSite)) { Credentials = Utilities.GetCredentials() };
IEnumerable<ServiceReferenceBSite.JobNumbersItem> jobList =
from jobNumbers in serviceReferenceBSite.JobNumbers
where !jobNumbers.JobStatus.Title.Contains("Job Complete")
orderby jobNumbers.JobNumber
select jobNumbers;
FYI. This project is using .NET 3.5 because I have a hook into the SharePoint Object Model! I would like to think that I can remove that hook and then use the .NET 4.0 framework so I could potentially us the dynamic datatype in a method that will return the correct Reference given the URI that is to be qureied by the ASP.NET site.
Hope this sounds clear enough and I hope someone out there is much smarter than me and knows how I can dynamically create any Service Reference-Reference without having to copy and paste my code a million times for each Service Reference I have.
Thanks James, for your input. I finally had time to prove my theory and it worked great.