Example #1
0
        /// <summary>
        ///
        /// </summary>
        public static void Clear()
        {
            var m         = Method.Caller("Ventus.DB");
            var backTrack = BE.BackTrack(m.Split('.')[0]);

            foreach (var t in backTrack.Where(o => o != null))
            {
                Clear(t.Name + ".");
            }
        }
Example #2
0
        private static object[] GetParams(string db, SqlTransaction xact, string sp, object o)
        {
            if (o == null)
            {
                return new object[] { null }
            }
            ;
            var type = o.GetType();

            if (type.IsEnum)
            {
                return new object[] { Convert.ToInt32(o) }
            }
            ;
            if (type.Namespace.Equals("System"))
            {
                return new[] { o }
            }
            ;
            SqlConnection cn = null;

            if (xact == null)
            {
                cn = GetConnection(db);
            }
            var sqlParams = DiscoverParameters(cn, xact, sp);
            var props     = BE.Properties(type).Where(q => q.CanRead).ToList();

            foreach (var param in sqlParams)
            {
                var prop = props.FirstOrDefault(p => param.ParameterName.Equals("@" + p.Name));
                if (prop != null)
                {
                    param.Value = prop.GetValue(o, null);
                }
            }
            var args = sqlParams.Select(p => p.Value).ToArray();

            return(args);
        }