/// <summary> /// 创建新的 TeamRole 对象。 /// </summary> /// <param name="id">ID 属性的初始值。</param> /// <param name="teamID">TeamID 属性的初始值。</param> /// <param name="roleID">RoleID 属性的初始值。</param> /// <param name="排">排 属性的初始值。</param> /// <param name="列">列 属性的初始值。</param> public static TeamRole CreateTeamRole(global::System.Guid id, global::System.Guid teamID, global::System.Guid roleID, global::System.Int32 排, global::System.Int32 列) { TeamRole teamRole = new TeamRole(); teamRole.ID = id; teamRole.TeamID = teamID; teamRole.RoleID = roleID; teamRole.排 = 排; teamRole.列 = 列; return teamRole; }
private void save(RanceEntities entites, Team team) { foreach (var item in team.TeamRole.ToArray()) entites.DeleteObject(item); if (team.第一排前列 != null && team.第一排前列.ID != Guid.Empty) { TeamRole teamRole = new TeamRole() { ID = Guid.NewGuid(), RoleID = team.第一排前列.ID, 列 = 1, 排 = 1, TeamID = team.ID, }; entites.TeamRole.AddObject(teamRole); } if (team.第一排中列 != null && team.第一排中列.ID != Guid.Empty) { TeamRole teamRole = new TeamRole() { ID = Guid.NewGuid(), RoleID = team.第一排中列.ID, 列 = 2, 排 = 1, TeamID = team.ID, }; entites.TeamRole.AddObject(teamRole); } if (team.第一排后列 != null && team.第一排后列.ID != Guid.Empty) { TeamRole teamRole = new TeamRole() { ID = Guid.NewGuid(), RoleID = team.第一排后列.ID, 列 = 3, 排 = 1, TeamID = team.ID, }; entites.TeamRole.AddObject(teamRole); } if (team.第二排前列 != null && team.第二排前列.ID != Guid.Empty) { TeamRole teamRole = new TeamRole() { ID = Guid.NewGuid(), RoleID = team.第二排前列.ID, 列 = 1, 排 = 2, TeamID = team.ID, }; entites.TeamRole.AddObject(teamRole); } if (team.第二排中列 != null && team.第二排中列.ID != Guid.Empty) { TeamRole teamRole = new TeamRole() { ID = Guid.NewGuid(), RoleID = team.第二排中列.ID, 列 = 2, 排 = 2, TeamID = team.ID, }; entites.TeamRole.AddObject(teamRole); } if (team.第二排后列 != null && team.第二排后列.ID != Guid.Empty) { TeamRole teamRole = new TeamRole() { ID = Guid.NewGuid(), RoleID = team.第二排后列.ID, 列 = 3, 排 = 2, TeamID = team.ID, }; entites.TeamRole.AddObject(teamRole); } if (team.第三排前列 != null && team.第三排前列.ID != Guid.Empty) { TeamRole teamRole = new TeamRole() { ID = Guid.NewGuid(), RoleID = team.第三排前列.ID, 列 = 1, 排 = 3, TeamID = team.ID, }; entites.TeamRole.AddObject(teamRole); } if (team.第三排中列 != null && team.第三排中列.ID != Guid.Empty) { TeamRole teamRole = new TeamRole() { ID = Guid.NewGuid(), RoleID = team.第三排中列.ID, 列 = 2, 排 = 3, TeamID = team.ID, }; entites.TeamRole.AddObject(teamRole); } if (team.第三排后列 != null && team.第三排后列.ID != Guid.Empty) { TeamRole teamRole = new TeamRole() { ID = Guid.NewGuid(), RoleID = team.第三排后列.ID, 列 = 3, 排 = 3, TeamID = team.ID, }; entites.TeamRole.AddObject(teamRole); } entites.SaveChanges(); }
/// <summary> /// 用于向 TeamRole EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet<T> 属性的 .Add 方法。 /// </summary> public void AddToTeamRole(TeamRole teamRole) { base.AddObject("TeamRole", teamRole); }