임에 DB를 새로 추가하고 DB를 작성하여 azure SQL DB에 트리거해야합니다.DB 트리거를 SQL DB에 작성하십시오.
먼저 모델로 MVC5 프로젝트를 만들고 DB 테이블을 반영한이 모델을 가지고 있습니다.
public class Employee
{
public int Id { get; set; }
public string EmployeeName { get; set; }
public string EmpAddress { get; set; }
public string EmpEmail { get; set; }
public string EmpPhone { get; set; }
}
public class EmployeeDbContext : DbContext
{
public EmployeeDbContext()
: base("DefaultConnection")
{
}
public DbSet<Employee> EmployeeCollection { get; set; }
}
}
는 지금은 그것을위한 DB 트리거를 만들려면 나는 다음과 같이하십시오. (나는 SO에서이 예제를 가지고 그것을 조정 ...)
Create Trigger Dbo.triggerName ON Employee
AFTER INSERT, Update, Delete
AS Begin
-- Log Deleted Rows and Old Value
Insert Into EmployeeCopy(Id ,EmployeeName, EmpAddress,EmpEmail,EmpPhone)
Select CURRENT_EMPLOYEE, Columns
From Deleted
-- Log Inserted Row and New Value
Insert Into EmployeeCopy(Id ,EmployeeName, EmpAddress,EmpEmail,EmpPhone)
Select CURRENT_EMPLOYEE, Columns
From Inserted
End
가 나는 그것이 새 테이블을 만들려면 EmployeeCopy이고 모든 행이 복사됩니다. 그래서이 내 질문에 (나는이 주제에 새) 귀하의 insert into
문이 변경 될 수 있습니다
1. what is the trigger name?
2.Do I write the Insert into right ?
3. Select CURRENT_EMPLOYEE, Columns ..Here Im not sure if this is the right way to write it?
트리거 이름은 트리거 이름을 원하는대로 지정할 수 있습니다. CopyEmployee. 삽입 위치는 EmployeeCopy (Id, EmployeeName, EmpAddress, EmpEmail, EmpPhone)입니다. ID, EmployeeName, EmpAddress, EmpEmail, EmpPhon을 선택하십시오. – TMNT2014