Guid guid = Guid.NewGuid(); string rid = guid.ToString(); rtList.Add(NewREMOTETAKEQUOTA("", sKind, 1, int.Parse(sMonday), int.Parse(sDefault),rid)); rtList.Add(NewREMOTETAKEQUOTA("", sKind, 2, int.Parse(sTuesday), int.Parse(sDefault), rid)); rtList.Add(NewREMOTETAKEQUOTA("", sKind, 3, int.Parse(sWednesday), int.Parse(sDefault), rid )); rtList.Add(NewREMOTETAKEQUOTA("", sKind, 4, int.Parse(sThursday), int.Parse(sDefault), rid)); rtList.Add(NewREMOTETAKEQUOTA("", sKind, 5, int.Parse(sFriday), int.Parse(sDefault), rid )); rtList.Add(NewREMOTETAKEQUOTA("", sKind, 6, int.Parse(sWeekdSaturdayays), int.Parse(sDefault), rid)); rtList.Add(NewREMOTETAKEQUOTA("", sKind, 0, int.Parse(sSunday), int.Parse(sDefault), rid)); rtRep.BatchInsert(rtList);
这样添加rid 这个 GUID的值都一样,会产生冲突 因为这个是PK ,有没有写法 让每行的GUID值都不一样?
每一个行都Guid.NewGuid().ToString()
一楼说的是正确的。
rtList.Add(NewREMOTETAKEQUOTA("", sKind, 1, int.Parse(sMonday), int.Parse(sDefault),Guid.NewGuid().ToString()));每个都将rid这样写Guid.NewGuid().ToString()