protected override void Execute(CodeActivityContext executionContext)
// Get the context service.
IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
// Use the context service to create an instance of IOrganizationService.
IOrganizationService _orgService = serviceFactory.CreateOrganizationService(context.InitiatingUserId);
// Use _orgService to call methods.
//Create a query expression specifying the Account entity and the columns that you want to return.
QueryExpression query = new QueryExpression("account");
query.ColumnSet.AddColumns("name", "websiteurl", "industrycode","ownershipcode","emailaddress1","address1_country","telephone1","createdon");//you can add columns as per your need.
//Create a filterexpression specifying the filter creteria.
query.Criteria = new FilterExpression();
//Adding the condition to the Query expresson which can filter records by Last month.
//Retrieving multiple data using IOrganizationService object through which call RetrieveMultiple method and pass the query.
EntityCollection results = _orgService.RetrieveMultiple(query);
Use the above method inside your custom workflow class to retrieve the details of record created in last month for Account entity.
Using the above query we can retrieve details of records created in last month for any crm 2011 entity and even we can also use this query in Soap Endpoint to retrieve metadata for the record created in last month.