hi there,
i have currently roughly this code for a lot of users in ousercol
it doesn't perform optimal
foreach(ent.UserEntity ouser in ousercol)
{
switch (ouser.Role)
{
case "ClientService":
CreateUserRole(ouser.Con_code,2);
break;
case "SystemAdmin":
CreateUserRole(ouser.Con_code,26);
CreateUserRole(ouser.Con_code,23);
CreateUserRole(ouser.Con_code,16);
break;
}
}
private void CreateUserRole(string concode,int roleid)
{
try
{
ent.Sec_user_roleEntity osur= new ent.Sec_user_roleEntity();
osur.Con_code=concode;
osur.Role_ID=roleid;
osur.Save();
}
catch(Exception ex)
{
}
}
how can i speed it up?
i have tried to place it in a collection and try to save the collection.
even with and without a transaction.
but my main problem with the collection is that when the Roles
already exists it gives a PK-violation, and it won't(?) get on with
the other records.