Exemplo n.º 1
0
        public override NHibernate.SqlCommand.SqlString OnPrepareStatement(NHibernate.SqlCommand.SqlString sql)
        {
            var a = sql.ToString();

            System.Console.WriteLine(sql.ToString());
            return(sql);
        }
Exemplo n.º 2
0
 public NHibernate.SqlCommand.SqlString OnPrepareStatement(NHibernate.SqlCommand.SqlString sql, ILogger <SqlStatementInterceptor> logger)
 {
     logger.Log(LogLevel.Error, "ERRRRRRRRRRRRRRRRRRRRRRRRROR!");
     logger.Log(LogLevel.Error, sql.ToString());
     SQLString.NHibernateSQLString = sql.ToString();
     return(sql);
 }
Exemplo n.º 3
0
        public override NHibernate.SqlCommand.SqlString OnPrepareStatement(NHibernate.SqlCommand.SqlString sql)
        {
            string qry = sql.ToString();

            //Trace.WriteLine(qry);
            return(sql);
        }
    //public string your property{ get; set; }

    NHibernate.SqlCommand.SqlString IInterceptor.OnPrepareStatement(NHibernate.SqlCommand.SqlString sql)
    {
        NHSessionManager.Instance.NHibernateSQL = sql.ToString();
        //property = sql.ToString();
        //Or
        //AsignSqlToSomeGlobalVariable(sql.ToString());
        return(sql);
    }
Exemplo n.º 5
0
    public override NHibernate.SqlCommand.SqlString OnPrepareStatement(NHibernate.SqlCommand.SqlString sql)
    {
        if (this.ActiveListener != null)
        {
            this.ActiveListener.OnPrepareStatement(sql.ToString());
        }

        return(base.OnPrepareStatement(sql));
    }
        private NHibernate.SqlCommand.SqlString FilterSQLToAvoidOtherUsersNewObjects(NHibernate.SqlCommand.SqlString sql)
        {
            string sqlstr = sql.ToString();

            if (sqlstr.Contains(".LockedBy") && sqlstr.Contains(".State"))
            {
                int whereindex   = sqlstr.IndexOf(" WHERE ", StringComparison.OrdinalIgnoreCase);
                int orderbyIndex = sqlstr.IndexOf(" ORDER BY ", StringComparison.OrdinalIgnoreCase);
                int fromIndex    = sqlstr.IndexOf(" FROM ", StringComparison.OrdinalIgnoreCase);

                string tableSynonym    = string.Empty;
                int    substringLength = sqlstr.IndexOfAny(new char[] { ' ', ',' }, sqlstr.IndexOf(' ', fromIndex + 6) + 1) - sqlstr.IndexOf(' ', fromIndex + 6) - 1;
                if (substringLength > 0)
                {
                    tableSynonym = sqlstr.Substring(sqlstr.IndexOf(' ', fromIndex + 6) + 1, substringLength);
                }
                else
                {
                    tableSynonym = sqlstr.Substring(sqlstr.IndexOf(' ', fromIndex + 6) + 1);
                }

                tableSynonym += ".";

                string whereStatment = " ((" + tableSynonym + "LockedBy is null) OR (" + tableSynonym + "LockedBy = '" + Environment.UserName + "') OR (" + tableSynonym + "LockedBy <> '" + Environment.UserName + "' AND " + tableSynonym + "State <> 1))";

                if (whereindex > -1)
                {
                    if (sqlstr.LastIndexOf(".LockedBy") < whereindex && sqlstr.LastIndexOf(".State") < whereindex)
                    {
                        if (orderbyIndex > -1)
                        {
                            sql = sql.Insert(orderbyIndex, " AND" + whereStatment);
                        }
                        else
                        {
                            sql = sql.Append(" AND" + whereStatment);
                        }
                    }
                }
                else
                {
                    if (orderbyIndex > -1)
                    {
                        sql = sql.Insert(orderbyIndex, " WHERE" + whereStatment);
                    }
                    else
                    {
                        sql = sql.Append(" WHERE" + whereStatment);
                    }
                }
            }

            return(sql);
        }
Exemplo n.º 7
0
 public override NHibernate.SqlCommand.SqlString OnPrepareStatement(NHibernate.SqlCommand.SqlString sql)
 {
     Debug.WriteLine(sql.ToString());
     return(sql);
 }
Exemplo n.º 8
0
 public override NHibernate.SqlCommand.SqlString OnPrepareStatement(NHibernate.SqlCommand.SqlString sql)
 {
     logger.LogTrace(sql.ToString());
     return(sql);
 }
Exemplo n.º 9
0
 public override NHibernate.SqlCommand.SqlString OnPrepareStatement(NHibernate.SqlCommand.SqlString sql)
 {
     System.Diagnostics.Trace.WriteLine(sql.ToString());
     return(sql);
 }
Exemplo n.º 10
0
 // http://stackoverflow.com/questions/2134565/how-to-configure-fluent-nhibernate-to-output-queries-to-trace-or-debug-instead-o
 public override NHibernate.SqlCommand.SqlString OnPrepareStatement(NHibernate.SqlCommand.SqlString sql)
 {
     Mapper.NHibernateSQL = sql.ToString();
     return(sql);
 }
Exemplo n.º 11
0
 public override NHibernate.SqlCommand.SqlString OnPrepareStatement(NHibernate.SqlCommand.SqlString sql)
 {
     LogHelper.SaveSQLToLog(sql.ToString());
     return(base.OnPrepareStatement(sql));
 }
Exemplo n.º 12
0
 public override NHibernate.SqlCommand.SqlString OnPrepareStatement(NHibernate.SqlCommand.SqlString sql)
 {
     Debug.Print(sql.ToString());
     return(base.OnPrepareStatement(sql));
 }
Exemplo n.º 13
0
 /// <summary>
 /// The prepared SQL statement is copied to <see cref="NHibernateSql.LastSqlStatement"/>.
 /// </summary>
 /// <param name="sqlStatement">The <see cref="NHibernate.SqlCommand.SqlString"/> to be prepared.</param>
 /// <returns>A <see cref="NHibernate.SqlCommand.SqlString"/>.</returns>
 NHibernate.SqlCommand.SqlString IInterceptor.OnPrepareStatement(NHibernate.SqlCommand.SqlString sqlStatement)
 {
     NHibernateSql.LastSqlStatement = sqlStatement.ToString();
     return(sqlStatement);
 }
Exemplo n.º 14
0
 public override NHibernate.SqlCommand.SqlString OnPrepareStatement(NHibernate.SqlCommand.SqlString sql)
 {
     Trace.WriteLine("NHibernate SQL: " + sql.ToString());
     return(sql);
 }