예제 #1
0
        protected override void ProcessRecord()
        {
            var connection = DatabaseConnection.Current;

            using (var command = new SqlCommand("Select [Extension],[IsImage],[Ignored] from [Extension] 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())
                    {
                        ImageStoreExtension line = new ImageStoreExtension(Id)
                        {
                            Extension = (string)reader[0],
                            IsImage   = (bool)reader[1],
                            Ignored   = (bool)reader[2]
                        };
                        WriteObject(line);
                    }
                    else
                    {
                        WriteObject(null);
                    }
                    reader.Close();
                }
            }
        }
        protected override void ProcessRecord()
        {
            var connection = DatabaseConnection.Current;

            using (var command = new SqlCommand("Select [Id],[Extension],[IsImage],[Ignored] from [Extension]"))
            {
                command.Connection = connection;
                WhereCauseBuilder whereCauseBuilder = new WhereCauseBuilder(command.Parameters);

                whereCauseBuilder.AddStringComparingCause("Extension", Extension, ExtensionPropertyComparingModes);
                whereCauseBuilder.AddBitComparingCause("IsImage", IsImage);
                whereCauseBuilder.AddBitComparingCause("Ignored", Ignored);

                command.CommandText += whereCauseBuilder.ToFullWhereCommand();

                List <ImageStoreExtension> result = new List <ImageStoreExtension>();

                using (var reader = command.ExecuteReader(System.Data.CommandBehavior.SequentialAccess))
                {
                    while (reader.Read())
                    {
                        ImageStoreExtension line = new ImageStoreExtension((Guid)reader[0])
                        {
                            Extension = (string)reader[1],
                            IsImage   = (bool)reader[2],
                            Ignored   = (bool)reader[3]
                        };
                        result.Add(line);
                    }
                    reader.Close();
                }

                WriteObject(result);
            }
        }
예제 #3
0
        internal static IEnumerable <ImageStoreExtension> GetAllExtensions()
        {
            var connection = DatabaseConnection.Current;

            using (var command = new SqlCommand("Select [Id],[Extension],[IsImage],[Ignored] from [Extension]"))
            {
                command.Connection = connection;
                using (var reader = command.ExecuteReader(System.Data.CommandBehavior.SequentialAccess))
                {
                    while (reader.Read())
                    {
                        ImageStoreExtension line = new ImageStoreExtension((Guid)reader[0])
                        {
                            Extension = (string)reader[1],
                            IsImage   = (bool)reader[2],
                            Ignored   = (bool)reader[3]
                        };
                        yield return(line);
                    }
                    reader.Close();
                }
            }
        }
예제 #4
0
        protected override void ProcessRecord()
        {
            if (Extension == null)
            {
                throw new ArgumentNullException(nameof(Extension));
            }

            var connection = DatabaseConnection.Current;

            using (var command = new SqlCommand("Select [Id],[Extension],[IsImage],[Ignored] from [Extension] Where [Extension]=@Extension"))
            {
                command.Connection = connection;
                command.Parameters.Add(new SqlParameter("@Extension", System.Data.SqlDbType.NVarChar, 256)
                {
                    Value = Extension
                });

                using (var reader = command.ExecuteReader(System.Data.CommandBehavior.SequentialAccess))
                {
                    if (reader.Read())
                    {
                        ImageStoreExtension line = new ImageStoreExtension((Guid)reader[0])
                        {
                            Extension = (string)reader[1],
                            IsImage   = (bool)reader[2],
                            Ignored   = (bool)reader[3]
                        };
                        WriteObject(line);
                    }
                    else
                    {
                        WriteObject(null);
                    }
                    reader.Close();
                }
            }
        }