Reputation: 641
I have a database which needs to be cleaned, yet I want to clean it dynamically. Each Table contains several fields and my requirement is that the "Trim()
" function be applied to all "String" fields.
Suppose I have two tables named CustomerInfo
and CustomerPayments
, My requirement is to first iterate over these tables and for each table, search for columns (fields) that have type of "String
" and then apply the Trim()
method to them.
Can I do that with LINQ?
I was using the following code to no avail since the CustomerInfo
class generated by Entity Framework does not implements GetProperties()
.
foreach (PropertyInfo propertyInfo in CustomerInfo.GetProperties())
Though I am truly in need of iterating table names in the base entity object as well.
Upvotes: 1
Views: 2116
Reputation: 48240
Shouldn't this be
foreach (PropertyInfo propertyInfo in typeof(CustomerInfo).GetProperties())
?
Upvotes: 2