public static void CreateSchema(this IQuery context, string name, string type) { if (!context.UserCanCreateSchema()) throw new InvalidOperationException(); // TODO: throw a specialized exception context.CreateObject(new SchemaInfo(name, type)); }
public static IJavascriptObject CreateEnum(this IJavascriptObjectFactory @this, Enum ienum) { try { var res = @this.CreateObject($"new Enum('{ienum.GetType().Name}',{Convert.ToInt32(ienum)},'{ienum.ToString()}','{ienum.GetDescription()}')"); if ((res == null) || (!res.IsObject)) throw ExceptionHelper.GetUnexpected(); return res; } catch { throw ExceptionHelper.Get($"Unexpected Error creating enum: {ienum}"); } }
public static IJavascriptObject CreateEnum(this IJavascriptObjectFactory @this, Enum ienum) { try { IJavascriptObject res = @this.CreateObject(string.Format("new Enum('{0}',{1},'{2}','{3}')", ienum.GetType().Name, Convert.ToInt32(ienum), ienum.ToString(), ienum.GetDescription())); if ((res == null) || (!res.IsObject)) throw ExceptionHelper.NoKoExtension(); return res; } catch { throw ExceptionHelper.NoKoExtension(); } }
public static void DefineView(this IQuery context, ViewInfo viewInfo, bool replaceIfExists) { var tablesInPlan = viewInfo.QueryPlan.DiscoverTableNames(); foreach (var tableName in tablesInPlan) { if (!context.UserCanSelectFromTable(tableName)) throw new InvalidAccessException(context.UserName(), tableName); } if (context.ViewExists(viewInfo.ViewName)) { if (!replaceIfExists) throw new InvalidOperationException( String.Format("The view {0} already exists and the REPLCE clause was not specified.", viewInfo.ViewName)); context.DropObject(DbObjectType.View, viewInfo.ViewName); } context.CreateObject(viewInfo); // The initial grants for a view is to give the user who created it // full access. using (var systemContext = context.Direct()) { systemContext.GrantToUserOnTable(viewInfo.ViewName, context.UserName(), Privileges.TableAll); } }
public static void CreateSequence(this ITransaction transaction, SequenceInfo sequenceInfo) { transaction.CreateObject(sequenceInfo); }
public static void CreateSchema(this ITransaction transaction, SchemaInfo schemaInfo) { transaction.CreateObject(schemaInfo); }
public static Variable DefineVariable(this ITransaction transaction, string name, SqlType type) { var variableInfo = new VariableInfo(name, type, false); transaction.CreateObject(variableInfo); return transaction.GetVariable(name); }
public static void DefineView(this IQueryContext context, ViewInfo viewInfo) { var tablesInPlan = viewInfo.QueryPlan.DiscoverTableNames(); foreach (var tableName in tablesInPlan) { if (!context.UserCanSelectFromTable(tableName)) throw new InvalidOperationException(String.Format("User '{0}' cannot access the table '{1}' in the view query plan.", context.User(), tableName)); } context.CreateObject(viewInfo); }
public static IEnumerable<Module> CreateModules(this IObjectSpace objectSpace, IEnumerable<ModuleChild> moduleChildren) { var groupBy = moduleChildren.GroupBy(GroupedModuleName); foreach (var group in groupBy) { var o = objectSpace.CreateObject<Module>(); o.Name = @group.Key; o.ModuleChilds.AddRange(group); yield return o; } }