Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Any setting to convert null strings to empty automatical
Message
 
 
General information
Forum:
ASP.NET
Category:
Entity Framework
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01608410
Message ID:
01608467
Views:
29
>Did I misunderstand your explanation. I thought you said:
>(a) SQL database does not allow Null strings ?
>(b) You were having a problem trying to save an empty C# string.
>If so then ConvertEmptyStringToNull(false) sounds like what you need.

Please read my original question carefully again.

I'll repeat the situation.

1. In our database we have columns which do not allow null values (all data types except dates are not-nullable in our database).

2. We're using Reverse POCO generator to generate our data and models and then custom scaffolding templates to generate view models, adapters, repository, angular forms, etc.

3. When we add a new row in our form, the string values are NULL unless we put values into them.

4. We need to save these NULL values as empty strings.

Our original solution was similar to discussed in that thread because the original code was saving strings in upper case. So, there was explicit code in the SaveChanges method that saved null strings as empty.

We later decided there is no need for converting all strings to upper case. So, I commented out the call to the conversion. As a result of this that new problem of saving NULL strings as empty strings arrived.

We can go back to the solutions suggested in the thread I mentioned by using some code in the SaveChanges method. I think the code in that thread is more efficient than our original.

Or, alternatively, we may try to implement getter for the property (it is actually the solution I implemented in a few ViewModels manually).

I think getter property sounds like a better idea. I already found the code where we may want to make this plug:
Entity = string.Format("public {0}{1} {2} {3}{4}", PropertyType, CheckNullable(this), PropertyNameHumanCase, IsStoreGenerated ? "{ get; internal set; }" : "{ get; set; }", comments);
I am also thinking I'll write a request to the author of the Reverse POCO generator to add some extra property and include this getter into new version of his generator.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform