Пример #1
0
        /// <summary>
        /// Get one register using only ID as key.
        /// </summary>
        /// <returns></returns>
        public virtual TagInfo GetValueByID(int TagID)
        {
            //ToDo: set multiple PK filter
            motor.ClearCommandParameters();
            motor.CommandText = GetSelectCommand() + GetWherePrimaryKey();
            List <DbParameter> paramList = new List <DbParameter>();


            DbParameter paramTagID = motor.Command.CreateParameter();

            paramTagID.ParameterName = "@param_TagID";
            paramTagID.Value         = TagID;
            paramList.Add(paramTagID);


            motor.AddCommandParameters(paramList);
            TagInfo InfoValue = new TagInfo();

            DbDataReader dbReader    = motor.ExecuteReader();
            ClassFiller  classFiller = new ClassFiller(typeof(TagInfo), dbReader);

            using (dbReader)
            {
                if (dbReader.Read())
                {
                    InfoValue = new TagInfo();
                    classFiller.Fill(InfoValue);
                }
                else
                {
                    return(null);
                }
            }
            return(InfoValue);
        }
Пример #2
0
        /// <summary>
        /// Performs one "select * from MyTable where [InformedProperties]". MinValues and nulls are skipped from filter.
        /// </summary>
        /// <param name="filter">EmployeeTerritoriesInfo</param>
        /// <returns>List of found records.</returns>
        public virtual List <EmployeeTerritoriesInfo> GetSome(EmployeeTerritoriesInfo filter)
        {
            List <EmployeeTerritoriesInfo> AllInfoList = new List <EmployeeTerritoriesInfo>();
            string             filterWhere             = string.Empty;
            List <DbParameter> paramList = null;

            GenerateWhere(filter, out filterWhere, out paramList);
            motor.ClearCommandParameters();
            motor.AddCommandParameters(paramList);
            motor.CommandText = GetSelectCommand() + " " + filterWhere;
            DbDataReader dbReader    = motor.ExecuteReader();
            ClassFiller  classFiller = new ClassFiller(typeof(EmployeeTerritoriesInfo), dbReader);

            using (dbReader)
            {
                while (dbReader.Read())
                {
                    EmployeeTerritoriesInfo EmployeeTerritoriesInfo = new EmployeeTerritoriesInfo();
                    ///Warning: performance issues with this automation. See method description for details.
                    classFiller.Fill(EmployeeTerritoriesInfo);
                    AllInfoList.Add(EmployeeTerritoriesInfo);
                }
            }
            return(AllInfoList);
        }
Пример #3
0
        /// <summary>
        /// Use parameters to apply simple filters
        /// </summary>
        /// <param name="filterExpression"></param>
        /// <returns></returns>
        public virtual List <EmployeeTerritoriesInfo> GetAll(List <DataFilterExpressionDB> filterExpression)
        {
            List <EmployeeTerritoriesInfo> AllInfoList = new List <EmployeeTerritoriesInfo>();

            motor.ClearCommandParameters();
            motor.CommandText = GetSelectCommand() + " where 1=1 ";
            List <DbParameter> paramList = new List <DbParameter>();

            string where = "";
            foreach (DataFilterExpressionDB filter in filterExpression)
            {
                DbParameter param = motor.Command.CreateParameter();
                param.ParameterName = "@param_" + filter.FieldName;
                param.Value         = filter.Filter;
                param.DbType        = HelperDBType.GetDBType(typeof(EmployeeTerritoriesInfo), filter.FieldName);
                if (filter.FilterType == DataFilterExpressionDB._FilterType.Equal)
                {
                    param.Value = filter.Filter;
                    where      += string.Format(" and EmployeeTerritories.{0} = {1}", filter.FieldName, param.ParameterName);
                }
                else
                {
                    param.Value = "%" + filter.Filter + "%";
                    where      += string.Format(" and EmployeeTerritories.{0} like {1}", filter.FieldName, param.ParameterName);
                }
                paramList.Add(param);
            }
            motor.CommandText += where;
            motor.AddCommandParameters(paramList);

            DbDataReader dbReader    = motor.ExecuteReader();
            ClassFiller  classFiller = new ClassFiller(typeof(EmployeeTerritoriesInfo), dbReader);

            using (dbReader)
            {
                while (dbReader.Read())
                {
                    EmployeeTerritoriesInfo classInfo = new EmployeeTerritoriesInfo();
                    classFiller.Fill(classInfo);
                    AllInfoList.Add(classInfo);
                }
            }
            return(AllInfoList);
        }
Пример #4
0
        /// <summary>
        /// Performs one "Select * from MyTable". Use wisely.
        /// </summary>
        /// <returns>List of found records.</returns>
        public virtual List <CustomerDemographicsInfo> GetAll()
        {
            List <CustomerDemographicsInfo> AllInfoList = new List <CustomerDemographicsInfo>();

            motor.CommandText = GetSelectCommand();
            DbDataReader dbReader    = motor.ExecuteReader();
            ClassFiller  classFiller = new ClassFiller(typeof(CustomerDemographicsInfo), dbReader);

            using (dbReader)
            {
                while (dbReader.Read())
                {
                    CustomerDemographicsInfo classInfo = new CustomerDemographicsInfo();
                    classFiller.Fill(classInfo);
                    AllInfoList.Add(classInfo);
                }
            }
            return(AllInfoList);
        }
Пример #5
0
        /// <summary>
        /// Same as get all but filter the result set
        /// </summary>
        /// <param name="numberOfRowsToSkip">Skip first X rows</param>
        /// <param name="numberOfRows">Like "TOP" in sql server</param>
        /// <returns></returns>
        public List <EmployeeTerritoriesInfo> GetAll(int numberOfRowsToSkip, int numberOfRows)
        {
            List <EmployeeTerritoriesInfo> AllInfoList = new List <EmployeeTerritoriesInfo>();

            motor.CommandText = base.GetFilteredRowNumAndSkipQuery("AttributeLists", "id", numberOfRowsToSkip, numberOfRows);
            DbDataReader dbReader    = motor.ExecuteReader();
            ClassFiller  classFiller = new ClassFiller(typeof(EmployeeTerritoriesInfo), dbReader);

            using (dbReader)
            {
                while (dbReader.Read())
                {
                    EmployeeTerritoriesInfo classInfo = new EmployeeTerritoriesInfo();
                    classFiller.Fill(classInfo);
                    AllInfoList.Add(classInfo);
                }
            }
            return(AllInfoList);
        }
Пример #6
0
        /// <summary>
        /// Performs one "Select * from MyTable". Use wisely.
        /// </summary>
        /// <returns>List of found records.</returns>
        public virtual List <EmployeeTerritoriesInfo> GetAll()
        {
            List <EmployeeTerritoriesInfo> AllInfoList = new List <EmployeeTerritoriesInfo>();

            motor.CommandText = GetSelectCommand();
            DbDataReader dbReader    = motor.ExecuteReader();
            ClassFiller  classFiller = new ClassFiller(typeof(EmployeeTerritoriesInfo), dbReader);

            using (dbReader)
            {
                while (dbReader.Read())
                {
                    EmployeeTerritoriesInfo classInfo = new EmployeeTerritoriesInfo();
                    classFiller.Fill(classInfo);
                    AllInfoList.Add(classInfo);
                }
            }
            return(AllInfoList);
        }
Пример #7
0
 private void A_string_property_difference(MappingTester<OutputClass> obj)
 {
     var source = new ClassFiller<InputClass>().Source;
     _context.Expected = new OutputClass
         {
             BooleanProperty = source.BooleanProperty,
             IntegerProperty = source.IntegerProperty,
             StringProperty = source.StringProperty,
             DecimalProperty = source.DecimalProperty,
             DateTimeProperty = source.DateTimeProperty
         };
     _context.Destination = new OutputClass
         {
             BooleanProperty = _context.Expected.BooleanProperty,
             StringProperty = _context.Expected.StringProperty.ToUpper(),
             DecimalProperty = _context.Expected.DecimalProperty,
             DateTimeProperty = _context.Expected.DateTimeProperty,
             IntegerProperty = _context.Expected.IntegerProperty
         };
     _expectedDifferenceMessage = "StringProperty";
 }
Пример #8
0
 private void Get_the_originally_generated_object(ClassFiller<InputClass> obj)
 {
     ReferenceEquals(_source, _classFiller.Source).ShouldBeTrue();
 }
Пример #9
0
 private static void Source_passed_as_object_type(SimpleMapper obj, ObjectSourceContext context)
 {
     var source = new ClassFiller<InputClass>().Source;
     context.Source = source;
     context.Expected = new OutputClass
                        {
                            BooleanProperty = source.BooleanProperty,
                            IntegerProperty = source.IntegerProperty,
                            StringProperty = source.StringProperty,
                            DecimalProperty = source.DecimalProperty,
                            DateTimeProperty = source.DateTimeProperty,
                            DateTimeToNullable = source.DateTimeToNullable
                        };
     context.Destination = new OutputClass();
 }
Пример #10
0
 private void Initialize_boolean_properties_with_non_default_values(ClassFiller<InputClass> obj)
 {
     _source.BooleanProperty.ShouldNotBeEqualTo(default(bool));
 }
Пример #11
0
 private static void NHibernate_dynamic_proxy_as_destination(SimpleMapper obj, DynamicDestinationContext context)
 {
     var source = new ClassFiller<InputClass>().Source;
     context.Source = source;
     context.Expected = new OutputClass
                        {
                            BooleanProperty = source.BooleanProperty,
                            IntegerProperty = source.IntegerProperty,
                            StringProperty = source.StringProperty,
                            DecimalProperty = source.DecimalProperty,
                            DateTimeProperty = source.DateTimeProperty,
                            DateTimeToNullable = source.DateTimeToNullable
                        };
     // ReSharper disable once RedundantCast
     context.Destination = new DynamicOutputClass();
 }
Пример #12
0
 private static void Source_initialized(SourceContext context)
 {
     var source = new ClassFiller<InputClass>().Source;
     context.Source = source;
     context.Expected = new OutputClass
                        {
                            BooleanProperty = source.BooleanProperty,
                            IntegerProperty = source.IntegerProperty,
                            StringProperty = source.StringProperty,
                            DecimalProperty = 0,
                            DateTimeProperty = source.DateTimeProperty,
                            DateTimeToNullable = source.DateTimeToNullable
                        };
     context.Destination = new OutputClass();
 }
Пример #13
0
 public void BeforeEachTest()
 {
     _classFiller = new ClassFiller<InputClass>();
     _source = _classFiller.Source;
 }
Пример #14
0
 private void The_desired_object_is_created(ClassFiller<InputClass> obj)
 {
     _source = obj.Source;
 }
Пример #15
0
 private void Not_return_a_null_object(ClassFiller<InputClass> obj)
 {
     _source.ShouldNotBeNull();
 }
Пример #16
0
 private void Initialize_string_properties_with_non_default_values(ClassFiller<InputClass> obj)
 {
     _source.StringProperty.ShouldNotBeEqualTo(default(string));
     _source.StringProperty.ShouldNotBeEqualTo("");
 }
Пример #17
0
 private void Initialize_integer_properties_with_non_default_values(ClassFiller<InputClass> obj)
 {
     _source.IntegerProperty.ShouldNotBeEqualTo(default(int));
 }