本文整理汇总了C#中User.Alter方法的典型用法代码示例。如果您正苦于以下问题:C# User.Alter方法的具体用法?C# User.Alter怎么用?C# User.Alter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User.Alter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddUserToRole
private static void AddUserToRole(User user, string role)
{
if (!(user.IsMember(role)))
{
user.AddToRole(role);
user.Alter();
}
}
示例2: AddUserToRoles
private static void AddUserToRoles(User user, params string[] roles)
{
if (roles.IsNullOrEmpty())
return;
foreach (var role in roles)
{
if (!(user.IsMember(role)))
{
user.AddToRole(role);
}
}
user.Alter();
}
示例3: Main
//.........这里部分代码省略.........
df1.Size = 10.0*1024.0;
df1.GrowthType = FileGrowthType.Percent;
df1.Growth = 25.0;
try
{
newDB.Create();
}
catch (Exception e)
{
WriteLine(string.Format("Could not create database \"{0}\"", newDatabase), OutputKind.Error);
ReportException(e);
WarnAndExit("");
}
}
//copy the users
foreach (User oldUser in db.Users)
{
User newUser = newDB.Users[oldUser.Name];
if (newUser == null)
{
Notify("Processing user " + oldUser.Name);
try
{
newUser = new User(newDB, oldUser.Name);
newUser.DefaultSchema = oldUser.DefaultSchema;
newUser.UserType = oldUser.UserType;
newUser.Login = oldUser.Login;
newDB.Users.Add(newUser);
newUser.Create();
StringCollection roles = oldUser.EnumRoles();
foreach (string role in roles) newUser.AddToRole(role);
newUser.Alter();
}
catch (Exception e)
{
ReportException(e);
}
}
}
//copy schemas
foreach (Schema oldSchema in db.Schemas)
{
Schema newSchema = newDB.Schemas[oldSchema.Name];
if (newSchema == null)
{
Notify("Processing schema " + oldSchema.Name);
try
{
newSchema = new Schema(newDB, oldSchema.Name);
newSchema.Owner = oldSchema.Owner;
newDB.Schemas.Add(newSchema);
newSchema.Create();
}
catch (Exception e)
{
ReportException(e);
}
}
}
//copy datatype
foreach (UserDefinedDataType oldType in db.UserDefinedDataTypes)
{
示例4: CreateUser
public void CreateUser(string name, string database, string defaultSchema, string login, string[] roles)
{
Database db = _server.Databases[database];
User user = new User(db, name) {Login = login, DefaultSchema = defaultSchema};
user.Create();
for (int i = 0; i < roles.Length; i++)
user.AddToRole(roles[i]);
user.Alter();
}