2010-12-27 2 views
0

LINQ-to-SQL을 사용할 때 여전히 몇 가지 문제가 있습니다. 나 혼자서도 답변을 찾고 있는데,이 문제는 너무 어색해서 찾으려는 키워드를 찾는데 문제가 있습니다. 메소드를 호출하기 전에Linq to SQL을 참조하여 FK를 참조 할 때

DB 주 :

public CustomTask SaveTask(string token, CustomTask task) 
    { 
     TrackingDataContext dataConext = new TrackingDataContext(); 

     //Check the token for security 
     if (SessionTokenBase.Instance.ExistsToken(Convert.ToInt32(token)) == null) return null; 

     //Populates the Task - the "real" Linq to SQL object    
     Task t = new Task(); 
     t.Title = task.Title; 
     t.Description = task.Description; 

//****The next 4 lines are important**** 
     if (task.Severity != null) 
      t.Severity = task.Severity; 
     else 
      t.SeverityID = task.SeverityID; 

     t.StateID = task.StateID; 

     if (task.TeamMember != null) 
      t.TeamMember = task.TeamMember; 
     else 
      t.ReporterID = task.ReporterID; 

     if (task.ReporterTeam != null) 
      t.Team = task.ReporterTeam; 
     else 
      t.ReporterTeamID = task.ReporterTeamID; 

     //Saves/Updates the task 
     dataConext.Tasks.InsertOnSubmit(t); 
     dataConext.SubmitChanges(); 

     task.ID = t.ID; 

     return task; 
    } 

문제는 내가이 상황을 얻을 때 나는, 그 심각성을 전송하고, 오전입니다 :

여기이 코드가

ID 이름 1 고 2 매체 3 낮은

호출 메소드 SELEC ID 이름 1 고 2 매체 3 로우 4 매체

요점은 : 메소드 호출 후 심각도

DB 상태로서 팅 "매체" 왜는이 엔트리가 중복 된 ??

코드에 대한 몇 가지 설명 : CustomTask 거의 작업과 동일하지만, 볼 수 있듯이 나는 직렬화에 대한 문제가되었다 here

편집 : 그냥 코드가 심각도 객체를 전송하고 있지 않은지 발견 신분증, 나는 그것을 바꿀거야.

답변

0

문제점이 발생, 휴식, 그래서 새로운 DataContext에 모든 호출을 생성 서비스가되는 것이 었습니다 인해 새로운 정보에 대한 질문을 업데이트 :하지만 여전히 항목 :(

Edit2가 중복하는 것이 매우 이상하다 ID를 사용하면이 문제를 피할 수 있습니다.

관련 문제