我有一个OData服务,该服务返回共享点列表的列表。 我无法枚举此列表。
是否有可能枚举它以便在foreach循环中循环遍历此Context中的列表?
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);
}
}
答案 0 :(得分:0)
知道了:
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;
}