public ActionResult Index() { // Get an instance of the QueryBuilder object var qb = _aqbs.GetOrCreate(instanceId, InitializeQueryBuilder); return(View(qb)); }
/// <summary> /// Creates and initializes new instance of the QueryBuilder object for the given identifier if it doesn't exist. /// </summary> /// <param name="name">Instance identifier of object in the current session.</param> /// <returns></returns> public ActionResult CreateQueryBuilder(string name) { try { // Create an instance of the QueryBuilder object _aqbs.GetOrCreate(name, qb => { qb.MetadataLoadingOptions.OfflineMode = true; qb.SyntaxProvider = new GenericSyntaxProvider(); // Initialize metadata var database = qb.MetadataContainer.AddSchema("dbo"); var orders = database.AddTable("Orders"); orders.AddField("Id"); orders.AddField("Name"); var customers = database.AddTable("Customers"); customers.AddField("Id"); customers.AddField("Name"); qb.MetadataStructure.Refresh(); }); return(StatusCode(200)); } catch (QueryBuilderException e) { return(StatusCode(400, e.Message)); } }
// Use IQueryBuilderService to get access to the server-side instances of Active Query Builder objects. // See the registration of this service in the Startup.cs. public ChangeConnectionController(IQueryBuilderService aqbs, IHostingEnvironment env, IConfiguration config) { _aqbs = aqbs; _env = env; _config = config; _aqbs.GetOrCreate(instanceId); }
public void Initialize() { // Get an instance of the QueryBuilder object var qb = _aqbs.GetOrCreate(instanceId, InitializeQueryBuilder); _qts.GetOrCreate(instanceId, t => { t.QueryProvider = qb.SQLQuery; t.AlwaysExpandColumnsInQuery = true; }); }
public ActionResult Index() { // Get an instance of the QueryBuilder object var qb = _aqbs.GetOrCreate(instanceId, InitializeQueryBuilder); var qt = _qts.GetOrCreate(instanceId, t => { t.QueryProvider = qb.SQLQuery; t.AlwaysExpandColumnsInQuery = true; }); ViewBag.QueryTransformer = qt; return(View(qb)); }
/// <summary> /// Creates and initializes new instance of the QueryBuilder object for the given identifier if it doesn't exist. /// </summary> /// <param name="name">Instance identifier of object in the current session.</param> /// <returns></returns> public ActionResult CreateQueryBuilder(string name) { try { // Create an instance of the QueryBuilder object _aqbs.GetOrCreate(name); return(StatusCode(200)); } catch (QueryBuilderException e) { return(StatusCode(400, e.Message)); } }
/// <summary> /// Creates and initializes new instance of the QueryBuilder object if it doesn't exist. /// </summary> public void CreateQueryBuilder() { // Get an instance of the QueryBuilder object _aqbs.GetOrCreate(instanceId, qb => { qb.SyntaxProvider = new MSSQLSyntaxProvider(); // Denies metadata loading requests from the metadata provider qb.MetadataLoadingOptions.OfflineMode = true; // Load MetaData from XML document. var path = _config["NorthwindXmlMetaData"]; var xml = Path.Combine(_env.WebRootPath, path); qb.MetadataContainer.ImportFromXML(xml); qb.SQL = GetDefaultSql(); }); }
/// <summary> /// Creates and initializes new instance of the QueryBuilder object for the given identifier if it doesn't exist. /// </summary> /// <param name="name">Instance identifier of object in the current session.</param> /// <returns></returns> public ActionResult Create(string name) { try { // Create an instance of the QueryBuilder object _aqbs.GetOrCreate(name, q => q.SQL = GetDefaultSql()); // The necessary initialization procedures to setup SQL syntax and the source of metadata will be performed automatically // according to directives in the special configuration section. // This behavior is enabled by the AddJsonFile or AddXmlFile methods call in the Startup method in Startup.cs file. // See qb.ConfiguredBy to get information about actual default settings } catch (Exception e) { Console.WriteLine(e); throw; } return(new EmptyResult()); }
// GET public IActionResult Index() { _aqbs.GetOrCreate(InstanceID, InitializeQueryBuilder); return(View()); }
// GET public IActionResult Index() { var qb = _aqbs.GetOrCreate("TagHelpers", InitializeQueryBuilder); return(View(qb)); }