Exemplo n.º 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);
        }