Repository Classes improvement suggested

Topics: General Discussion Forum, July and December Releases Forum, Service Factory Modeling Edition Forum
Sep 3, 2007 at 12:53 PM
Edited Sep 7, 2007 at 4:54 PM
Hi,


Imagine a table "Customers" has the following fields:
CustomerID int
CreatedDate datetime default getdate() not null

then, you create the business entity class, and stored procedures for it.

then, create the repository classes for this.

the problem is in InsertFactory, that it doesn't handle default values, instead there is:
db.AddInParameter(command, "createdDate", DbType.DateTime, customer.CreatedDate);

But, it can be improved as following:

When a field is "Not Null", and has default value in that Table, then that field should not be passed to the stored procedure:

if (customer.CreatedDate != null)
{
db.AddInParameter(command, "createdDate", DbType.String, customer.CreatedDate);
}

I have this problem and raises error for me. I have to pass the default value of this field, which is specified in Table as getdate(), to this parameter from Code.


Regards
Coordinator
Sep 6, 2007 at 10:51 PM
This would be another great post for the Repository Factory discussion.