private async Task UpdateMembers(Resource resource, IPatch patch)
        {
            if (null == resource)
            {
                throw new ArgumentNullException(FileProvider.ArgumentNameResource);
            }

            if (null == patch)
            {
                throw new ArgumentNullException(FileProvider.ArgumentNamePatch);
            }

            if (null == patch.ResourceIdentifier)
            {
                throw new ArgumentException(ProvisioningAgentResources.ExceptionInvalidPatch);
            }

            if (string.IsNullOrWhiteSpace(patch.ResourceIdentifier.Identifier))
            {
                throw new ArgumentException(ProvisioningAgentResources.ExceptionInvalidPatch);
            }

            if (string.IsNullOrWhiteSpace(patch.ResourceIdentifier.SchemaIdentifier))
            {
                throw new ArgumentException(ProvisioningAgentResources.ExceptionInvalidPatch);
            }

            if (null == patch.PatchRequest)
            {
                throw new ArgumentException(ProvisioningAgentResources.ExceptionInvalidPatch);
            }

            PatchRequest2 patchRequest = patch.PatchRequest as PatchRequest2;
            if (null == patchRequest)
            {
                string unsupportedPatchTypeName = patch.GetType().FullName;
                throw new NotSupportedException(unsupportedPatchTypeName);
            }

            if
            (
                !FileProvider
                .SchemaIdentifiersGroup
                .Value
                .Any(
                    (string item) =>
                        string.Equals(item, patch.ResourceIdentifier.SchemaIdentifier, StringComparison.Ordinal))
            )
            {
                return;
            }

            IReadOnlyCollection<PatchOperation> memberOperations =
                patchRequest
                .Operations
                .Where(
                    (PatchOperation item) =>
                            item.Path != null
                        && string.Equals(item.Path.AttributePath, AttributeNames.Members, StringComparison.Ordinal))
                .ToArray();
            if (!memberOperations.Any())
            {
                return;
            }

            foreach (PatchOperation memberOperation in memberOperations)
            {
                if (null == memberOperation.Value)
                {
                    continue;
                }
                
                foreach (OperationValue value in memberOperation.Value)
                {
                    if (string.IsNullOrWhiteSpace(value.Value))
                    {
                        continue;
                    }

                    Dictionary<string, string> columnsQuery = 
                        new Dictionary<string,string>()
                            {
                                {
                                    AttributeNames.Schemas,
                                    patch.ResourceIdentifier.SchemaIdentifier
                                },
                                {
                                    AttributeNames.Identifier,
                                    patch.ResourceIdentifier.Identifier
                                },
                                {
                                    AttributeNames.Members,
                                    value.Value
                                }
                            };
                    IRow[] rows = await this.file.Query(columnsQuery);

                    switch (memberOperation.Name)
                    {
                        case OperationName.Add:
                            if (rows.Any())
                            {
                                break;
                            }

                            Member member = 
                                new Member()
                                    {
                                        Value = value.Value
                                    };
                            MemberColumnsFactory memberColumnsFactory = new MemberColumnsFactory(resource, member);
                            IReadOnlyDictionary<string, string> columnsMember = memberColumnsFactory.CreateColumns();
                            await this.file.InsertRow(columnsMember);
                            break;

                        case OperationName.Remove:
                            foreach (IRow row in rows)
                            {
                                await this.file.RemoveRow(row.Key);
                            }

                            break;
                    }
                }
            }
        }
        public override async Task<Resource> Create(Resource resource, string correlationIdentifier)
        {
            logger.Info("creating resource");

            if (null == resource)
            {
                throw new ArgumentNullException(FileProvider.ArgumentNameResource);
            }

            if (string.IsNullOrWhiteSpace(correlationIdentifier))
            {
                throw new ArgumentNullException(FileProvider.ArgumentNameCorrelationIdentifier);
            }

            if (string.IsNullOrWhiteSpace(resource.Identifier))
            {
                throw new ArgumentException(ProvisioningAgentResources.ExceptionInvalidResource);
            }

            string informationStarting =
                string.Format(
                    CultureInfo.InvariantCulture,
                    AzureTestProvisioningResources.InformationCreating,
                    resource.Identifier);
            ProvisioningAgentMonitor.Instance.Inform(informationStarting, true, correlationIdentifier);

            ColumnsFactory columnsFactory;

            WindowsAzureActiveDirectoryGroup group = resource as WindowsAzureActiveDirectoryGroup;
            if (group != null)
            {
                columnsFactory = new GroupColumnsFactory(group);
            }
            else
            {
                Core2EnterpriseUser user = resource as Core2EnterpriseUser;
                if (user != null)
                {
                    columnsFactory = new UserColumnsFactory(user);
                }
                else
                {
                    string unsupportedSchema =
                        string.Join(
                            Environment.NewLine,
                            resource.Schemas);
                    throw new NotSupportedException(unsupportedSchema);
                }
            }

            IReadOnlyDictionary<string, string> columns = columnsFactory.CreateColumns();
            IRow row = await this.file.InsertRow(columns);

            ResourceFactory resourceFactory;
            if (group != null)
            {
                resourceFactory = new GroupFactory(row);
            }
            else
            {
                resourceFactory = new UserFactory(row);
            }

            Resource result = resourceFactory.CreateResource();

            if (group != null && group.Members != null && group.Members.Any())
            {
                foreach (Member member in group.Members)
                {
                    MemberColumnsFactory memberColumnsFactory = new MemberColumnsFactory(result, member);
                    IReadOnlyDictionary<string, string> memberColumns = memberColumnsFactory.CreateColumns();
                    await this.file.InsertRow(memberColumns);
                }
            }

            return result;
        }