我一直在一个新项目中使用EF6代码优先方法,这很棒,但是现在我在如何自定义CRUD存储过程上有些挣扎,以便在数据库中计算某些列。 / p>
过程(抽象):
public abstract class Process
{
public int Id {get; set}
public int Name {get; set}
public DateTime CreateDate{get; private set}
public DateTime UpdateDate{get; private set}
public virtual ICollection<ProcessContact> Contacts { get; set; }
}
ProcessContact:
public class ProcessContact
{
public string Name {get; set}
public string Value {get; set}
}
ProcessA:
public class ProcessA: Process
{
public int A {get; set}
}
ProcessB:
public class ProcessB: Process
{
public int B {get; set}
}
以上述3个类为例,我如何以EF6代码为先,自定义生成的存储过程,以便例如:
Process
时,将Id
设置为count(*)+1
和CreateDate = GETUTCTIME()
ProcessContact
时,请在UpdateDate = GETUTCTIME()
表中设置Process