protected override void ProcessRecord() { var connection = DatabaseConnection.Current; using (var command = new SqlCommand("Select [Id],[FolderId],[Directory],[IsSubDirectoryIncluded] from [IgnoredDirectory]")) { command.Connection = connection; WhereCauseBuilder whereCauseBuilder = new WhereCauseBuilder(command.Parameters); whereCauseBuilder.AddUniqueIdentifierComparingCause("FolderId", FolderId); whereCauseBuilder.AddStringComparingCause("Directory", Directory, DirectoryPropertyComparingModes); whereCauseBuilder.AddBitComparingCause("IsSubDirectoryIncluded", IsSubDirectoryIncluded); command.CommandText += whereCauseBuilder.ToFullWhereCommand(); List <ImageStoreIgnoredDirectory> result = new List <ImageStoreIgnoredDirectory>(); using (var reader = command.ExecuteReader(System.Data.CommandBehavior.SequentialAccess)) { while (reader.Read()) { ImageStoreIgnoredDirectory line = new ImageStoreIgnoredDirectory((Guid)reader[0]) { FolderId = (Guid)reader[1], Directory = (string)reader[2], IsSubDirectoryIncluded = (bool)reader[3] }; result.Add(line); } reader.Close(); } WriteObject(result); } }
protected override void ProcessRecord() { var connection = DatabaseConnection.Current; using (var command = new SqlCommand("Select [FolderId],[Directory],[IsSubDirectoryIncluded] from [IgnoredDirectory] Where [Id]=@Id")) { command.Connection = connection; command.Parameters.Add(new SqlParameter("@Id", System.Data.SqlDbType.UniqueIdentifier) { Value = Id }); using (var reader = command.ExecuteReader(System.Data.CommandBehavior.SequentialAccess)) { if (reader.Read()) { ImageStoreIgnoredDirectory line = new ImageStoreIgnoredDirectory(Id) { FolderId = (Guid)reader[0], Directory = (string)reader[1], IsSubDirectoryIncluded = (bool)reader[2] }; WriteObject(line); } else { WriteObject(null); } reader.Close(); } } }
internal static IEnumerable <ImageStoreIgnoredDirectory> GetAllIgnoredDirectories(Guid folderId) { var connection = DatabaseConnection.Current; using (var command = new SqlCommand("Select [Id],[Directory],[IsSubDirectoryIncluded] from [IgnoredDirectory] Where [FolderId]=@FolderId")) { command.Connection = connection; command.Parameters.Add(new SqlParameter("@FolderId", System.Data.SqlDbType.UniqueIdentifier) { Value = folderId }); using (var reader = command.ExecuteReader(System.Data.CommandBehavior.SequentialAccess)) { while (reader.Read()) { ImageStoreIgnoredDirectory line = new ImageStoreIgnoredDirectory((Guid)reader[0]) { FolderId = folderId, Directory = (string)reader[1], IsSubDirectoryIncluded = (bool)reader[2] }; yield return(line); } reader.Close(); } } }
protected override void ProcessRecord() { if (Directory == null) { throw new ArgumentNullException(nameof(Directory)); } var connection = DatabaseConnection.Current; using (var command = new SqlCommand("Select [Id],[Directory] from [IgnoredDirectory] Where [FolderId]=@FolderId and [Directory]=@Directory and [IsSubDirectoryIncluded]=@IsSubDirectoryIncluded")) { command.Connection = connection; command.Parameters.Add(new SqlParameter("@FolderId", System.Data.SqlDbType.UniqueIdentifier) { Value = FolderId }); command.Parameters.Add(new SqlParameter("@Directory", System.Data.SqlDbType.NVarChar, 256) { Value = Directory }); command.Parameters.Add(new SqlParameter("@IsSubDirectoryIncluded", System.Data.SqlDbType.Bit) { Value = IsSubDirectoryIncluded }); using (var reader = command.ExecuteReader(System.Data.CommandBehavior.SequentialAccess)) { if (reader.Read()) { ImageStoreIgnoredDirectory line = new ImageStoreIgnoredDirectory((Guid)reader[0]) { FolderId = FolderId, Directory = (string)reader[1], IsSubDirectoryIncluded = IsSubDirectoryIncluded }; WriteObject(line); } else { WriteObject(null); } reader.Close(); } } }