I have a OData service that returns a list of sharepoint lists. I am unable to enumerate this list.
Is it possible to enumerate this to be able to loop through the lists in this Context in a foreach loop?
public class ODService
{
private DataContext _Context;
private NetworkCredential _nc;
public DataContext Context { get { return _Context; } }
/// <summary>
/// Constructor creates the context for access to sharepoint
/// </summary>
/// <param name="UserName">Service Account User Name</param>
/// <param name="Password">Service Account Password</param>
/// <param name="uri">Service uri</param>
public ODService(string UserName, string Password, string uri)
{
SetNetworkCredentials(UserName, Password);
SetContext(uri);
}
private void SetContext(string uri)
{
_Context = new DataContext(new Uri(uri));
_Context.Credentials = _nc;
_Context.MergeOption = MergeOption.NoTracking;
}
private void SetNetworkCredentials(string UserName, string Password)
{
_nc = new NetworkCredential(UserName, Password);
}
}
Got it:
public IList<string> EntityList()
{
IList<string> PropertyList = new List<string>();
var Properties = typeof(DataContext).GetProperties();
foreach (var property in Properties)
{
PropertyList.Add(property.Name);
}
return PropertyList;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.