public static class IPluginExecutionContextExtension
{
public static Microsoft.Xrm.Sdk.Entity GetPrimaryEntity(this Microsoft.Xrm.Sdk.IPluginExecutionContext context)
{
var inputeParameter = context.InputParameters;
if (inputeParameter.Contains("Target") &&
inputeParameter["Target"] is Microsoft.Xrm.Sdk.Entity)
{
return inputeParameter["Target"] as Microsoft.Xrm.Sdk.Entity;
}
return null;
}
public static Microsoft.Xrm.Sdk.Entity GetPreImageEntity(this Microsoft.Xrm.Sdk.IPluginExecutionContext context, string imageKey)
{
if (context.PreEntityImages.Contains(imageKey))
{
return context.PreEntityImages[imageKey];
}
return null;
}
public static Microsoft.Xrm.Sdk.Entity GetPostImageEntity(this Microsoft.Xrm.Sdk.IPluginExecutionContext context, string imageKey)
{
if (context.PostEntityImages.Contains(imageKey))
{
return context.PostEntityImages[imageKey];
}
return null;
}
}
}
Entity currentCase = context.GetPrimaryEntity();
Entity preCase = context.GetPreImageEntity("preImage");
Entity postCase = context.GetPostImageEntity("postImage");
Here we are using Extension method of .NET.
{
public static Microsoft.Xrm.Sdk.Entity GetPrimaryEntity(this Microsoft.Xrm.Sdk.IPluginExecutionContext context)
{
var inputeParameter = context.InputParameters;
if (inputeParameter.Contains("Target") &&
inputeParameter["Target"] is Microsoft.Xrm.Sdk.Entity)
{
return inputeParameter["Target"] as Microsoft.Xrm.Sdk.Entity;
}
return null;
}
public static Microsoft.Xrm.Sdk.Entity GetPreImageEntity(this Microsoft.Xrm.Sdk.IPluginExecutionContext context, string imageKey)
{
if (context.PreEntityImages.Contains(imageKey))
{
return context.PreEntityImages[imageKey];
}
return null;
}
public static Microsoft.Xrm.Sdk.Entity GetPostImageEntity(this Microsoft.Xrm.Sdk.IPluginExecutionContext context, string imageKey)
{
if (context.PostEntityImages.Contains(imageKey))
{
return context.PostEntityImages[imageKey];
}
return null;
}
}
}
Entity currentCase = context.GetPrimaryEntity();
Entity preCase = context.GetPreImageEntity("preImage");
Entity postCase = context.GetPostImageEntity("postImage");
Here we are using Extension method of .NET.
No comments:
Post a Comment