File tree 1 file changed +9
-1
lines changed
FSharp/FSharpRepoDB/FSharpRepoDB
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ let main argv =
47
47
Console.WriteLine( " Insert<TEntity>: Generated Id = {0}" , Convert.ToString( id))
48
48
49
49
// Insert(TableName)
50
- let person = {| Name = " James Smith" ; Age = 32 ; Address = " Washington" ; IsActive = true |}
50
+ let person = {| Name = " James Smith" ; Age = 32 ; Address = " Washington" ; IsActive = false |}
51
51
let id = connection.Insert< int64>( ClassMappedNameCache.Get< Person>(), person)
52
52
Console.WriteLine( " Insert(TableName): Generated Id = {0}" , Convert.ToString( id))
53
53
@@ -59,6 +59,14 @@ let main argv =
59
59
let result = connection.QueryAll( ClassMappedNameCache.Get< Person>()) .AsList()
60
60
Console.WriteLine( " QueryAll(TableName): Count = {0}" , result.Count)
61
61
62
+ // Query with anonymous records, pull only what you need
63
+ let result =
64
+ connection.ExecuteQuery<{| Name: string ; Age: int |}>(
65
+ @" SELECT Name, Age FROM [dbo].[Person] WHERE IsActive = @isactive" ,
66
+ dict([ " @isactive" , box false ])
67
+ ) .AsList()
68
+ printfn " ExecuteQuery(SQL query): Count = %i \n\t First Value =\n\t '%A '" result.Count ( result |> Seq.tryHead)
69
+
62
70
// Dispose the connection
63
71
connection.Dispose()
64
72
You can’t perform that action at this time.
0 commit comments