0 people like it.

LiteDb read with SQL

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
23: 
open LiteDB

[<CLIMutable>]
type Customer =
    {
        Id: int
        Name: string
        Phones: string[]
        IsActive: bool
    }

let db = new LiteDatabase(@"C:\Temp\MyData.db")
let col = db.GetCollection<Customer>("customers")
let customer = { Id = 0; Name = "John Doe"; Phones = [| "867-5309" |]; IsActive = true }
col.Insert(customer)

let reader = db.Execute("SELECT $ FROM customers")
let mapper = BsonMapper()
let customers = 
    [|
        while reader.Read() do
            mapper.Deserialize<Customer>(reader.Current)
    |]
namespace LiteDB
Multiple items
type CLIMutableAttribute =
  inherit Attribute
  new : unit -> CLIMutableAttribute

--------------------
new : unit -> CLIMutableAttribute
type Customer =
  { Id: int
    Name: string
    Phones: string []
    IsActive: bool }
Customer.Id: int
Multiple items
val int : value:'T -> int (requires member op_Explicit)

--------------------
type int = int32

--------------------
type int<'Measure> = int
Customer.Name: string
Multiple items
val string : value:'T -> string

--------------------
type string = System.String
Customer.Phones: string []
Customer.IsActive: bool
type bool = System.Boolean
val db : LiteDatabase
Multiple items
type LiteDatabase =
  new : connectionString:string * ?mapper:BsonMapper -> LiteDatabase + 3 overloads
  member BeginTrans : unit -> bool
  member Checkpoint : unit -> unit
  member CheckpointSize : int with get, set
  member Collation : Collation
  member CollectionExists : name:string -> bool
  member Commit : unit -> bool
  member Dispose : unit -> unit
  member DropCollection : name:string -> bool
  member Execute : commandReader:TextReader * ?parameters:BsonDocument -> IBsonDataReader + 2 overloads
  ...

--------------------
LiteDatabase(connectionString: string,?mapper: BsonMapper) : LiteDatabase
LiteDatabase(connectionString: ConnectionString,?mapper: BsonMapper) : LiteDatabase
LiteDatabase(stream: System.IO.Stream,?mapper: BsonMapper,?logStream: System.IO.Stream) : LiteDatabase
LiteDatabase(engine: Engine.ILiteEngine,?mapper: BsonMapper,?disposeOnClose: bool) : LiteDatabase
val col : ILiteCollection<Customer>
LiteDatabase.GetCollection<'T>() : ILiteCollection<'T>
LiteDatabase.GetCollection<'T>(autoId: BsonAutoId) : ILiteCollection<'T>
LiteDatabase.GetCollection(name: string,?autoId: BsonAutoId) : ILiteCollection<BsonDocument>
LiteDatabase.GetCollection<'T>(name: string,?autoId: BsonAutoId) : ILiteCollection<'T>
val customer : Customer
ILiteCollection.Insert(entities: System.Collections.Generic.IEnumerable<Customer>) : int
ILiteCollection.Insert(entity: Customer) : BsonValue
ILiteCollection.Insert(id: BsonValue, entity: Customer) : unit
val reader : IBsonDataReader
LiteDatabase.Execute(command: string, [<System.ParamArray>] args: BsonValue []) : IBsonDataReader
LiteDatabase.Execute(command: string,?parameters: BsonDocument) : IBsonDataReader
LiteDatabase.Execute(commandReader: System.IO.TextReader,?parameters: BsonDocument) : IBsonDataReader
val mapper : BsonMapper
Multiple items
type BsonMapper =
  new : ?customTypeInstantiator:Func<Type, obj> * ?typeNameBinder:ITypeNameBinder -> BsonMapper
  val ResolveFieldName : Func<string, string>
  val ResolveMember : Action<Type, MemberInfo, MemberMapper>
  val ResolveCollectionName : Func<Type, string>
  member Deserialize<'T> : value:BsonValue -> 'T + 1 overload
  member EmptyStringToNull : bool with get, set
  member Entity<'T> : unit -> EntityBuilder<'T>
  member EnumAsInteger : bool with get, set
  member GetExpression<'T, 'K> : predicate:Expression<Func<'T, 'K>> -> BsonExpression
  member GetIndexExpression<'T, 'K> : predicate:Expression<Func<'T, 'K>> -> BsonExpression
  ...

--------------------
BsonMapper(?customTypeInstantiator: System.Func<System.Type,obj>,?typeNameBinder: ITypeNameBinder) : BsonMapper
val customers : Customer []
IBsonDataReader.Read() : bool
BsonMapper.Deserialize<'T>(value: BsonValue) : 'T
BsonMapper.Deserialize(type: System.Type, value: BsonValue) : obj
property IBsonDataReader.Current: BsonValue with get
Raw view Test code New version

More information

Link:http://fssnip.net/892
Posted:2 years ago
Author:
Tags: