/// <summary> /// Adds a Sql Server data handler /// </summary> /// <param name="root">Root of the request to handle</param> /// <param name="services">Services where to add the handler</param> /// <param name="options">Sql options</param> /// <returns>Services with the handler</returns> public static IServiceCollection AddSql4GP(this IServiceCollection services, string root, Action <SqlDataOptions> options) { if (string.IsNullOrEmpty(root)) { throw new ArgumentNullException(nameof(root)); } // Add handler var opt = new SqlDataOptions(); options.Invoke(opt); services.AddTransient <IRestRequestHandler>(x => { var mem = x.GetRequiredService <IMemoryCache>(); var dataOpt = x.GetRequiredService <DataRequestOptions>(); return(new SqlRestHandler(root, opt, mem, dataOpt)); }); // Returns the service collection return(services); }
/// <summary> /// Creates a new instance of SqlRestHandler /// </summary> /// <param name="root">Root of the request to handle</param> /// <param name="sqlOptions">Sql options</param> /// <param name="memoryCache">Memory cache implementation</param> /// <param name="options">Data option</param> public SqlRestHandler(string root, SqlDataOptions sqlOptions, IMemoryCache memoryCache, DataRequestOptions options) : base(root, new SqlDataContext(sqlOptions), memoryCache, options) { }
/// <summary> /// Creates a new instance of SqlViewManager /// </summary> /// <param name="metadata">View metadata</param> /// <param name="options">Sql data options</param> public SqlViewManager(EntityMetadata metadata, SqlDataOptions options) { EntityMetadata = metadata ?? throw new ArgumentNullException(nameof(options)); Options = options ?? throw new ArgumentNullException(nameof(options)); }
/// <summary> /// Creates a new instance of SqlDataContext /// </summary> /// <param name="options">Options</param> public SqlDataContext(SqlDataOptions options = null) { Options = options ?? new SqlDataOptions(); }
/// <summary> /// Creates a new instance of SqlTableManager /// </summary> /// <param name="metadata">Table metadata</param> /// <param name="options">Sql data options</param> public SqlTableManager(EntityMetadata metadata, SqlDataOptions options) : base(metadata, options) { }