DAL 更新方法的通用方法签名
我正在使用一个多用途存储过程,它可以为声明或保单执行插入或更新。我只想创建一个 DAL 方法来调用此更新/插入。
我有一个 IBaseAdjustment,其中包含声明对象和策略对象的所有属性。 Claim是Policy的子集,因此它将继承Policy。如果没有传入任何值,存储过程将设置为默认值,因此我尽可能使用可为空的属性。
我被困在更新调用的方法签名上。我
public bool UpdateManualAdjustmentTransaction<T>() where T : IBaseAdjustment
{}
只是不确定现在如何设置对我的实体的引用来设置参数,我本以为它会是类似的东西,
IbaseAdjustment _adjustment = T as IBaseAdjustment;
但它不喜欢那样。建议? '谢谢
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 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您只是要使用该接口,则根本不需要将其作为通用方法:
这将允许您将任一实体直接传递给此方法。
If you're just going to use the interface, there is no need for this to be a generic method at all:
This will let you pass either of your entities to this method directly.