New Posts New Posts RSS Feed: Insert NULL Into Database Field
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Insert NULL Into Database Field

 Post Reply Post Reply
Author
cjohnson84 View Drop Down
Groupie
Groupie


Joined: 24-Sep-2009
Location: Akron, Ohio
Posts: 44
Post Options Post Options   Quote cjohnson84 Quote  Post ReplyReply Direct Link To This Post Topic: Insert NULL Into Database Field
    Posted: 27-Jul-2010 at 11:20am

I have bound the contents of the "Employees" table in my database to a datagrid in my DevForce 2010 Silverlight application.

The "MiddleName" field in the "Employees" table is defined as a Nullable Varchar(30) in the database.
 
If I edit records in the datagrid and then save back to the database how do I ensure that NULL values are written back to the database instead of empty strings for the "MiddleName" field if the "MiddleName" field was left blank in the datagrid? 
Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Posted: 28-Jul-2010 at 4:19pm

A BeforeSet property interceptor action would do the trick.  I guess you could generalize it further to any entity, and in the logic in the interceptor determine if the set should be cancelled.

 

Back to Top
cjohnson84 View Drop Down
Groupie
Groupie


Joined: 24-Sep-2009
Location: Akron, Ohio
Posts: 44
Post Options Post Options   Quote cjohnson84 Quote  Post ReplyReply Direct Link To This Post Posted: 30-Jul-2010 at 12:22pm
Thank you for the suggestion!  I was able to add a "BeforeSet" method to my injected Baseentity class to solve the problem.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down