Normally, I can query the class below like so:
this._xrmServiceContext.AccountSet.FirstOrDefault(x => x.Id == someGuid);
however, during compile time we don't know whether it is AccountSet, or AccountLeadSet, or 500 other queryables.
I would like to have functionality that will return a binding to XrmServiceContext, something like:
_xrmServiceContextBind.Where(var querable => iquerableName == name + "Set").FirstOrDefault(x => x.Id == someGuid)
the defintiion of XrmServiceContext is below:
public partial class XrmServiceContext : Microsoft.Xrm.Sdk.Client.OrganizationServiceContext
{
/// <summary>
/// Constructor.
/// </summary>
public XrmServiceContext(Microsoft.Xrm.Sdk.IOrganizationService service) :
base(service)
{
}
/// <summary>
/// Gets a binding to the set of all <see cref="Xrm.Account"/> entities.
/// </summary>
public System.Linq.IQueryable<Xrm.Account> AccountSet
{
get
{
return this.CreateQuery<Xrm.Account>();
}
}
/// <summary>
/// Gets a binding to the set of all <see cref="Xrm.AccountLeads"/> entities.
/// </summary>
public System.Linq.IQueryable<Xrm.AccountLeads> AccountLeadsSet
{
get
{
return this.CreateQuery<Xrm.AccountLeads>();
}
}
/// <summary>
/// Gets a binding to the set of all <see cref="Xrm.ActivityMimeAttachment"/> entities.
/// </summary>
public System.Linq.IQueryable<Xrm.ActivityMimeAttachment> ActivityMimeAttachmentSet
{
get
{
return this.CreateQuery<Xrm.ActivityMimeAttachment>();
}
}
/// <summary>
/// Gets a binding to the set of all <see cref="Xrm.ActivityParty"/> entities.
/// </summary>
public System.Linq.IQueryable<Xrm.ActivityParty> ActivityPartySet
{
get
{
return this.CreateQuery<Xrm.ActivityParty>();
}
}
/// <summary>
/// Gets a binding to the set of all <see cref="Xrm.ActivityPointer"/> entities.
/// </summary>
public System.Linq.IQueryable<Xrm.ActivityPointer> ActivityPointerSet
{
get
{
return this.CreateQuery<Xrm.ActivityPointer>();
}
}
}
How do I query the AccountSet or ActivityPointerSet, or any other set, knowing only the name of the set during run time?