Generic Method Signature for DAL Update method
I am working with a multi-purpose Stored Procedure that does either an insert or update for either Claim or Policy. I would like to only create one DAL method to call this update/insert.
I have a IBaseAdjustment that contains all of the properties of both a Claim Object and a Policy Object. Claim is a subset of Policy so It will inherit Policy. The stored procedure is set up to default to values if none are passed in so therefore I am using nullable properties where possible.
I am stuck on the method signature for the Update call. I have
public bool UpdateManualAdjustmentTransaction<T>() where T : IBaseAdjustment
{}
I am just not sure how to set the reference to my entity now开发者_C百科 to set the parameters I would have thought it would be something like
IbaseAdjustment _adjustment = T as IBaseAdjustment;
but it does not like that. Suggestions? 'Thanks
If you're just going to use the interface, there is no need for this to be a generic method at all:
public bool UpdateManualAdjustmentTransaction(IBaseAdjustment baseAdjustment)
{
// use baseAdjustment
}
This will let you pass either of your entities to this method directly.
精彩评论