'Declaration Public MustInherit Class SQLiteScalarFunction Inherits SQLiteFunction Implements System.IDisposable
public abstract class SQLiteScalarFunction : SQLiteFunction, System.IDisposable
'Declaration Public MustInherit Class SQLiteScalarFunction Inherits SQLiteFunction Implements System.IDisposable
public abstract class SQLiteScalarFunction : SQLiteFunction, System.IDisposable
Use this class to derive classes for user-defined scalar functions from it.
The scalar function is a simple function, that returns a scalar value and is executed once when called.
To register the user-defined scalar funtion, create the class, derived from SQLiteScalarFunction and pass its name and number of arguments to the base class constructor.
You should also override the Invoke method, which should implement the function actions.
public class MyFunction : SQLiteScalarFunction { public MyFunction() : base("Sqrt", 1) { } protected override object Execute(object[] args, SQLiteConnection connection) { return Math.Sqrt(Convert.ToDouble(args[0])); } } ... SQLiteConnection sqLiteConnection = new SQLiteConnection(@"Data Source=D:\SQLite\test.db"); sqLiteConnection.Open(); MyFunction function = new MyFunction(); sqLiteConnection.RegisterFunction(function); SQLiteCommand command = new SQLiteCommand("select sqrt(9.0)", sqLiteConnection); double result = (double)command.ExecuteScalar(); sqLiteConnection.UnRegisterFunction(function); sqLiteConnection.Close();
System.Object
Devart.Data.SQLite.SQLiteFunction
Devart.Data.SQLite.SQLiteScalarFunction
Devart.Data.SQLite.SQLiteScalarFunction<TResult>
Devart.Data.SQLite.SQLiteScalarFunction<T1,TResult>
Devart.Data.SQLite.SQLiteScalarFunction<T1,T2,TResult>
Devart.Data.SQLite.SQLiteScalarFunction<T1,T2,T3,TResult>
Devart.Data.SQLite.SQLiteScalarFunction<T1,T2,T3,T4,TResult>
Devart.Data.SQLite.SQLiteScalarFunction<T1,T2,T3,T4,T5,TResult>
Devart.Data.SQLite.SQLiteScalarFunction<T1,T2,T3,T4,T5,T6,TResult>
Devart.Data.SQLite.SQLiteScalarFunction<T1,T2,T3,T4,T5,T6,T7,TResult>
Devart.Data.SQLite.SQLiteScalarFunction<T1,T2,T3,T4,T5,T6,T7,T8,TResult>