So, I’m importing data from one database into another. There are about 5,000 records (so nothing ridiculous, but not small enough to eyeball). Is there an easy way to automatically truncate data that is too long – specifically, varchar fields? I don’t want truncation to be silent since the too-long fields will likely require attention, but it would be really nice if a name that is 2 characters too long wouldn’t fail on insert, and throw a totally non-specific exception.
The solution I’d like to implement is one that will truncate the data, insert it, and log this. Has anyone else done something similar?
Linq2Sql will generate a property like this:
See how it calls a function called
OnNameChanged? Just create a function with that name to do the truncation and logging: