WebApplications.Testing.Data.SqlExceptionPrototype.SqlExceptionPrototype C# (CSharp) Method

SqlExceptionPrototype() static private method

Creates the _constructor lambda.
static private SqlExceptionPrototype ( ) : System
return System
        static SqlExceptionPrototype()
        {
            // Find SqlError constructor (note we don't get about the overload that accepts uint win32ErrorCode
            MethodInfo methodInfo =
                typeof(SqlException).GetMethod(
                    "CreateException",
                    BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.InvokeMethod,
                    null,
                    new[]
                    {
                        typeof(SqlErrorCollection),
                        typeof(string),
                        typeof(Guid),
                        typeof(Exception)
                    },
                    null);
            Debug.Assert(methodInfo != null);

            // Create parameters
            List<ParameterExpression> parameters = new List<ParameterExpression>(4)
            {
                Expression.Parameter(
                    typeof(SqlErrorCollection),
                    "errorCollection"),
                Expression.Parameter(typeof(string), "serverVersion"),
                Expression.Parameter(typeof(Guid), "conId"),
                Expression.Parameter(typeof(Exception), "innerException")
            };

            // Create lambda expression.
            _constructor = Expression.Lambda<Func<SqlErrorCollection, string, Guid, Exception, SqlException>>(
                Expression.Call(methodInfo, parameters),
                parameters).Compile();
        }

Same methods

SqlExceptionPrototype::SqlExceptionPrototype ( SqlErrorCollection errorCollection, string serverVersion = null, System.Guid conId = default(Guid), Exception innerException = null ) : System
SqlExceptionPrototype::SqlExceptionPrototype ( [ exception ) : System