Beispiel #1
0
        private SqlParameter ReadParameter(PersistenceOperatorParameter poParameter, object value)
        {
            SqlParameter parameter = new SqlParameter();

            parameter.ParameterName = "@" + poParameter.Name;
            parameter.DbType        = poParameter.DbType;
            if (!NullFinder.IsNull(poParameter.Size, "System.Int32"))
            {
                parameter.Size = poParameter.Size;
            }
            parameter.Direction  = poParameter.Direction;
            parameter.IsNullable = true;
            if (!NullFinder.IsNull(poParameter.Precision, "System.Byte"))
            {
                parameter.Precision = poParameter.Precision;
            }
            if (!NullFinder.IsNull(poParameter.Scale, "System.Byte"))
            {
                parameter.Scale = poParameter.Scale;
            }
            if ((parameter.Direction != ParameterDirection.ReturnValue) && !NullFinder.IsNull(value, value.GetType().FullName))
            {
                parameter.Value = value;
            }
            return(parameter);
        }
Beispiel #2
0
        private XmlDocument GetXml(string filterTemplate, IDataFilter filter)
        {
            SqlConnection connection = new SqlConnection(connString);
            SqlCommand    command    = new SqlCommand(filterTemplate, connection);

            command.CommandTimeout = 120;
            command.CommandType    = System.Data.CommandType.StoredProcedure;
            string        filterExpression = filter.GetFilterExpression(filterTemplate);
            XmlSerializer s = new XmlSerializer(typeof(List <SQLDataFilterParameter>));
            List <SQLDataFilterParameter> filterParameters = (List <SQLDataFilterParameter>)s.Deserialize(new StringReader(filterExpression));

            foreach (SQLDataFilterParameter filterParameter in filterParameters)
            {
                SqlParameter parameter = new SqlParameter();
                parameter.ParameterName = "@" + filterParameter.Name;
                if (filterParameter.Value != null && filterParameter.Value != string.Empty)
                {
                    parameter.DbType = filterParameter.Type;
                    parameter.Value  = NullFinder.Parse(filterParameter.Value, filterParameter.ValueType);
                }
                //parameter.Size = filterParameter.Size;
                parameter.Direction  = filterParameter.Direction;
                parameter.IsNullable = true;
                //parameter.Precision = filterParameter.Precision;
                //parameter.Scale = filterParameter.Scale;
                command.Parameters.Add(parameter);
            }
            connection.Open();

            XmlReader   reader   = command.ExecuteXmlReader();
            XmlDocument document = new XmlDocument();

            document.Load(reader);
            reader.Close();
            connection.Close();
            return(document);

            //Stream xmlStream = File.OpenRead(connString.Trim());
            //return XmlReader.Create(xmlStream);
        }