I am developing a RIA Domain Service that will use a POCO Entity Data Model. There is some fixup required with the default Domain Service template due to the fact that POCO classes do not implement the EntityState property, as does EntityObject.
Julie Lerman provides the solution:
OLD: if ((customer.EntityState == EntityState.Detached))
NEW: if ((GetEntityState(customer) != EntityState.Detached))
The problem is that I may have to regenerate the domain service several times over the course of my development, and there are lots of tables/entities to deal with.
The Question:
Can the “OLD” above be replaced with the “NEW” using a regex? It’s a very predictable pattern:
- Find instances of
'.EntityState'- Replace with ‘
GetEntityState([text between ( and .])‘
Using Visual Studio Find and Replace (and with Use Regular Expressions on, of course):
Find what:
if \(\({:i}\.EntityState == EntityState\.Detached\)\)Replace with:
if ((GetEntityState(\1) == EntityState.Detached))Edit
The OP seems to prefer Expresso. In that case it would be like this:
Regular Expression:
if \(\((\w+)\.EntityState == EntityState\.Detached\)\)Replacement String:
if ((GetEntityState($1) == EntityState.Detached))(Also fixed the
!=typo)