views:

26

answers:

2

Hi,

We are using linq-to-sql entities,and want to implement trimming for all string properties.One way is on submitchanges,using reflection trim all string properties.Is there any other way?

thanks

A: 

If you don't want to use reflection, you can implement the code generator to use generate the proper code with Trim() on all string procedures.

Another way is to get the context object and do the trimming on the submit part of the process.

I'm too sleepy now, as it's 1:45am here, to remember the proper code to do it. But it's possible, because I did something similar using Linq-to-Entities.


Edited to add

Take a look at my site. This code generator I made is for Linq-to-Entities but should be similar for Linq-to-SQL.

Paulo Santos
Any idea how code generator can be made to do this?
junky_user
A: 

Trim on the get/set of your properties.

Esteban Araya
Yes,thats the simplest thing to do.But, we have so many entities,so we have to go through each of them and do it.
junky_user