Trimming Spaces on Deserialization in WCF Services -


My usual requirement is to keep a common way to ensure that no leading / trailing spaces are stored in the database Our architecture is WCF- & gt; Business Logic Manager- & gt; Genetic repository-> Unit Framework 5.0 - & gt; DB

Now I have 2 ways to do this

  1. Do this on normal storage (but here I have to find the whole object graph for string properties and change the value
  2. Do this while decryaging the WCF pipeline (but here I may have to keep my custom serializer, which I want to wish that I want to do, is an event during the serialization where I A Check the type of property and change its value)

    I am in favor of Approach 2, but without changing the entire serializer, finding the easiest way to do this is to custom It can be changed without using the serializer. We are currently using XmlSerializer.

    Looking for the following input (2)

    1. Which approach would be better in performance
    2. How do I get a little bit in the current serial process in my WCF pipeline C method.

      Thanks, AV

      Your code works at the data layer And should not be on the serialization layer, given that where the requirement has arisen.

      For implementation, you have two options.

      You can either use DbChangeTracker or you can use IDbCommandInterceptor (new in EF6) to change the behavior of your EF reference. You can.

      How you can easily do this with the change tracker

        public category FooContext: DbContext {public override int SaveChanges () {var items = ChangeTracker.Entries (). Where (E = & gt; E. State == Entitestate was added) .toList (); Foreign items (different item in item) foreign currency (different property in property property name) {var propValue = item [property] as string; If (preview! = Null) {item [property] = pvt.tim (); }} Return base. Save Changes (); }}    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -