private Expression CreateQueryableFunctionQueryRootExpression( IDbFunction function, IReadOnlyCollection <Expression> arguments) { var entityType = _model.FindEntityType(function.MethodInfo.ReturnType.GetGenericArguments()[0]); return(new QueryableFunctionQueryRootExpression(entityType, function, arguments)); }
public static DataSet GetAsDataSet([NotNull] this IDbFunction dbFunction, [NotNull] Func <dynamic, object> function) { CodeContracts.ArgumentNotNull(dbFunction, "dbFunction"); CodeContracts.ArgumentNotNull(function, "function"); return((DataSet)function(dbFunction.GetDataSet)); }
public static DataTable GetAsDataTable([NotNull] this IDbFunction dbFunction, [NotNull] Func <dynamic, object> function) { CodeContracts.VerifyNotNull(dbFunction, "dbFunction"); CodeContracts.VerifyNotNull(function, "function"); return((DataTable)function(dbFunction.GetData)); }
/// <summary> /// Initializes a new instance of the <see cref="BasicRepository{T}"/> class. /// </summary> /// <param name="dbFunction"> /// The db function. /// </param> /// <param name="dbAccess"> /// The db Access. /// </param> /// <param name="raiseEvent"> /// The raise Event. /// </param> /// <param name="haveBoardId"> /// The have Board Id. /// </param> public BasicRepository(IDbFunction dbFunction, IDbAccess dbAccess, IRaiseEvent raiseEvent, IHaveBoardID haveBoardId) { this.DbFunction = dbFunction; this.DbAccess = dbAccess; this.DbEvent = raiseEvent; this.BoardID = haveBoardId.BoardID; }
public static T GetScalar <T>([NotNull] this IDbFunction dbFunction, [NotNull] Func <dynamic, object> function) { CodeContracts.VerifyNotNull(dbFunction, "dbFunction"); CodeContracts.VerifyNotNull(function, "function"); return(((object)function(dbFunction.Scalar)).ToType <T>()); }
/// <summary> /// Determines whether [is full text supported]. /// </summary> /// <param name="dbFunction">The database function.</param> /// <returns> /// Returns if full text is supported by the server or not /// </returns> public static bool IsFullTextSupported([NotNull] this IDbFunction dbFunction) { CodeContracts.VerifyNotNull(dbFunction, "dbFunction"); return(dbFunction.ValidateAndExecute( "IsFullTextSupported", f => f.GetScalar <bool>(s => s.IsFullTextSupported()))); }
private static T ValidateAndExecute <T>(this IDbFunction dbFunction, string operationName, Func <IDbFunction, T> func) { if (!dbFunction.DbSpecificFunctions.WhereOperationSupported(operationName).Any()) { throw new InvalidOperationException(@"Database Provider does not support operation ""{0}"".".FormatWith(operationName)); } return(func(dbFunction)); }
/// <summary> /// The change recovery mode. /// </summary> /// <param name="dbFunction"> /// The db function. /// </param> /// <param name="recoveryMode"> /// The recovery mode. /// </param> /// <returns> /// The <see cref="string"/>. /// </returns> public static string ChangeRecoveryMode( [NotNull] this IDbFunction dbFunction, string recoveryMode) { CodeContracts.VerifyNotNull(dbFunction, "dbFunction"); return(dbFunction.ValidateAndExecute( "ChangeRecoveryMode", f => f.Scalar.ChangeRecoveryMode(recoveryMode))); }
/// <summary> /// The system initialize fix access. /// </summary> /// <param name="dbFunction"> /// The db function. /// </param> /// <param name="grantAccess"> /// The grant access. /// </param> public static void SystemInitializeFixAccess( [NotNull] this IDbFunction dbFunction, bool grantAccess) { CodeContracts.VerifyNotNull(dbFunction, "dbFunction"); dbFunction.ValidateAndExecute( "SystemInitializeFixAccess", f => f.Scalar.SystemInitializeFixAccess(grantAccess)); }
//Since this is always generated while compiling there is no query provider associated public QueryableFunctionQueryRootExpression( [NotNull] IEntityType entityType, [NotNull] IDbFunction function, [NotNull] IReadOnlyCollection <Expression> arguments) : base(entityType) { Check.NotNull(function, nameof(function)); Check.NotNull(arguments, nameof(arguments)); Function = function; Arguments = arguments; }
public static IEnumerable <T> GetDataTyped <T>( [NotNull] this IDbFunction dbFunction, [NotNull] Func <object, object> function, [CanBeNull] IEqualityComparer <string> comparer = null) where T : IDataLoadable, new() { CodeContracts.VerifyNotNull(dbFunction, "dbFunction"); CodeContracts.VerifyNotNull(function, "function"); return(dbFunction.GetData(function).Typed <T>(comparer)); }
/// <summary> /// The run sql. /// </summary> /// <param name="dbFunction"> /// The db function. /// </param> /// <param name="sql"> /// The sql. /// </param> /// <param name="useTransaction"> /// The use transaction. /// </param> /// <returns> /// The <see cref="string"/>. /// </returns> public static string RunSQL( [NotNull] this IDbFunction dbFunction, string sql, bool useTransaction) { CodeContracts.VerifyNotNull(dbFunction, "dbFunction"); return(dbFunction.ValidateAndExecute( "RunSQL", f => f.Scalar.RunSQL(sql, useTransaction))); }
/// <summary> /// The system initialize execute scripts. /// </summary> /// <param name="dbFunction"> /// The db function. /// </param> /// <param name="script"> /// The script. /// </param> /// <param name="scriptFile"> /// The script file. /// </param> /// <param name="useTransactions"> /// The use transactions. /// </param> public static void SystemInitializeExecuteScripts( [NotNull] this IDbFunction dbFunction, [NotNull] string script, [NotNull] string scriptFile, bool useTransactions) { CodeContracts.VerifyNotNull(dbFunction, "dbFunction"); dbFunction.ValidateAndExecute( "SystemInitializeExecuteScripts", f => f.Scalar.SystemInitializeExecuteScripts(script, scriptFile, useTransactions)); }
/// <summary> /// Initializes a new instance of the <see cref="YafDbBroker" /> class. /// </summary> /// <param name="serviceLocator">The service locator.</param> /// <param name="boardSettings">The board settings.</param> /// <param name="httpSessionState">The http session state.</param> /// <param name="dataCache">The data cache.</param> /// <param name="dbFunction">The database function.</param> public YafDbBroker( IServiceLocator serviceLocator, YafBoardSettings boardSettings, HttpSessionStateBase httpSessionState, IDataCache dataCache, IDbFunction dbFunction) { this.ServiceLocator = serviceLocator; this.BoardSettings = boardSettings; this.HttpSessionState = httpSessionState; this.DataCache = dataCache; this.DbFunction = dbFunction; }
/// <summary> /// Initializes a new instance of the <see cref="DataBroker" /> class. /// </summary> /// <param name="serviceLocator">The service locator.</param> /// <param name="boardSettings">The board settings.</param> /// <param name="httpSessionState">The http session state.</param> /// <param name="dataCache">The data cache.</param> /// <param name="dbFunction">The database function.</param> public DataBroker( IServiceLocator serviceLocator, BoardSettings boardSettings, HttpSessionStateBase httpSessionState, IDataCache dataCache, IDbFunction dbFunction) { this.ServiceLocator = serviceLocator; this.BoardSettings = boardSettings; this.HttpSessionState = httpSessionState; this.DataCache = dataCache; this.DbFunction = dbFunction; }
public void DbFunction_IsQueryable() { var modelBuilder = GetModelBuilder(); var queryableNoParams = typeof(MyDerivedContext) .GetRuntimeMethod(nameof(MyDerivedContext.QueryableNoParams), Array.Empty <Type>()); IDbFunction function = modelBuilder.HasDbFunction(queryableNoParams).Metadata; var model = modelBuilder.FinalizeModel(); function = model.FindDbFunction(function.ModelName); var entityType = model.FindEntityType(typeof(Foo)); Assert.True(function.IsQueryable); Assert.Same(entityType, function.QueryableEntityType); }
public static string ToDebugString( [NotNull] this IDbFunction function, MetadataDebugStringOptions options, int indent = 0) { var builder = new StringBuilder(); var indentString = new string(' ', indent); builder .Append(indentString) .Append("DbFunction: "); builder.Append(function.ReturnType.ShortDisplayName()) .Append(" "); if (function.Schema != null) { builder .Append(function.Schema) .Append("."); } builder.Append(function.Name); if ((options & MetadataDebugStringOptions.SingleLine) == 0) { var parameters = function.Parameters.ToList(); if (parameters.Count != 0) { builder.AppendLine().Append(indentString).Append(" Parameters: "); foreach (var parameter in parameters) { builder.AppendLine().Append(parameter.ToDebugString(options, indent + 4)); } } if ((options & MetadataDebugStringOptions.IncludeAnnotations) != 0) { builder.Append(function.AnnotationsToDebugString(indent: indent + 2)); } } return(builder.ToString()); }
/// <summary> /// Initializes a new instance of the <see cref="MsSqlSearch"/> class. /// </summary> /// <param name="dbFunction">The database function.</param> public MsSqlSearch(IDbFunction dbFunction) { this._dbFunction = dbFunction; }
public static void InsertMethod(IDbFunction oIDb) { oIDb.Insert(); }
/// <summary> /// Gets the size of the database. /// </summary> /// <param name="dbFunction">The database function.</param> /// <returns>Returns the size of the database</returns> public static int GetDBSize([NotNull] this IDbFunction dbFunction) { CodeContracts.VerifyNotNull(dbFunction, "dbFunction"); return(dbFunction.ValidateAndExecute("DBSize", f => f.GetScalar <int>(s => s.DBSize()))); }
/// <summary> /// The re index database. /// </summary> /// <param name="dbFunction"> /// The db function. /// </param> /// <returns> /// The <see cref="string"/>. /// </returns> public static string ReIndexDatabase([NotNull] this IDbFunction dbFunction) { CodeContracts.VerifyNotNull(dbFunction, "dbFunction"); return(dbFunction.ValidateAndExecute("ShrinkDatabase", f => f.GetScalar <string>(s => s.ReIndexDatabase()))); }
private void Create( IDbFunction function, string functionsVariable, CSharpRuntimeAnnotationCodeGeneratorParameters parameters) { if (function.Translation != null) { throw new InvalidOperationException(RelationalStrings.CompiledModelFunctionTranslation(function.Name)); } if (function is IConventionDbFunction conventionFunction && conventionFunction.GetTypeMappingConfigurationSource() != null) { throw new InvalidOperationException(RelationalStrings.CompiledModelFunctionTypeMapping( function.Name, "Customize()", parameters.ClassName)); } AddNamespace(function.ReturnType, parameters.Namespaces); var code = Dependencies.CSharpHelper; var functionVariable = code.Identifier( function.MethodInfo?.Name ?? function.Name, parameters.ScopeVariables, capitalize: false); var mainBuilder = parameters.MainBuilder; mainBuilder .Append("var ").Append(functionVariable).AppendLine(" = new RuntimeDbFunction(").IncrementIndent() .Append(code.Literal(function.ModelName)).AppendLine(",") .Append(parameters.TargetName).AppendLine(",") .Append(code.Literal(function.ReturnType)).AppendLine(",") .Append(code.Literal(function.Name)); if (function.Schema != null) { mainBuilder.AppendLine(",") .Append("schema: ").Append(code.Literal(function.Schema)); } if (function.StoreType != null) { mainBuilder.AppendLine(",") .Append("storeType: ").Append(code.Literal(function.StoreType)); } if (function.MethodInfo != null) { var method = function.MethodInfo; mainBuilder.AppendLine(",") .Append("methodInfo: ").Append(code.Literal(method.DeclaringType !)).AppendLine(".GetMethod(").IncrementIndent() .Append(code.Literal(method.Name !)).AppendLine(",") .Append(method.IsPublic ? "BindingFlags.Public" : "BindingFlags.NonPublic") .Append(method.IsStatic ? " | BindingFlags.Static" : " | BindingFlags.Instance") .AppendLine(" | BindingFlags.DeclaredOnly,") .AppendLine("null,") .Append("new Type[] { ").Append(string.Join(", ", method.GetParameters().Select(p => code.Literal((Type)p.ParameterType)))).AppendLine(" },") .Append("null)").DecrementIndent(); } if (function.IsScalar) { mainBuilder.AppendLine(",") .Append("scalar: ").Append(code.Literal(function.IsScalar)); } if (function.IsAggregate) { mainBuilder.AppendLine(",") .Append("aggregate: ").Append(code.Literal(function.IsAggregate)); } if (function.IsNullable) { mainBuilder.AppendLine(",") .Append("nullable: ").Append(code.Literal(function.IsNullable)); } if (function.IsBuiltIn) { mainBuilder.AppendLine(",") .Append("builtIn: ").Append(code.Literal(function.IsBuiltIn)); } mainBuilder.AppendLine(");").DecrementIndent() .AppendLine(); var parameterParameters = parameters with { TargetName = functionVariable }; foreach (var parameter in function.Parameters) { Create(parameter, parameterParameters); } CreateAnnotations( function, Generate, parameters with { TargetName = functionVariable });
/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> public FunctionMapping(IEntityType entityType, StoreFunction storeFunction, IDbFunction dbFunction, bool includesDerivedTypes) : base(entityType, storeFunction, includesDerivedTypes) { DbFunction = dbFunction; }
private Expression CreateQueryableFunctionQueryRootExpression( IDbFunction function, IReadOnlyCollection <Expression> arguments) => new QueryableFunctionQueryRootExpression(function.QueryableEntityType, function, arguments);
/// <summary> /// Gets the current SQL Engine Edition. /// </summary> /// <param name="dbFunction">The database function.</param> /// <returns> /// Returns the current SQL Engine Edition. /// </returns> public static string GetSQLEngine([NotNull] this IDbFunction dbFunction) { CodeContracts.VerifyNotNull(dbFunction, "dbFunction"); return(dbFunction.ValidateAndExecute("GetSQLEngine", f => f.GetScalar <string>(s => s.GetSQLEngine()))); }
private Expression CreateTableValuedFunctionQueryRootExpression( IDbFunction function, IReadOnlyCollection <Expression> arguments) => new TableValuedFunctionQueryRootExpression(function.ReturnEntityType, function, arguments);