2015-09-22 10 views

उत्तर

8

आप डेटाबेस पर सभी कॉल को रोकने के लिए IDbCommandInterceptor का उपयोग कर सकते हैं। फिर पारित होने वाले किसी भी पैरामीटर को ट्रिम करें।

अधिक जानकारी के लिए this article देखें और विशेष रूप से इंटरसेप्टर को कैसे पंजीकृत करें।

class TrimCommandInterceptor: IDbCommandInterceptor 
{ 
    public void NonQueryExecuting(DbCommand command, DbCommandInterceptionContext<int> ctx) 
    { 
    foreach (var p in command.Parameters) 
    { 
     if (p.Value is string) 
     p.Value = ((string) p.Value).Trim(); 
    } 
    } 

    // Add all the other interceptor methods 
} 
संबंधित मुद्दे