-
Notifications
You must be signed in to change notification settings - Fork 5
Basic concepts
Jacek edited this page Jun 27, 2017
·
24 revisions
How to represent queries in code? Of course, as functions. Query parameters should be reflected as function parameters, their results as function result types.
E.g. the query
select id, name, title, description, owner, createdAt, modifiedAt, modifiedBy
from Blog
where id = @id
could be implemented as a function of type:
int -> DataContext-> Blog
SqlFun alows to generate such a function:
let getBlog: int -> DataContext -> Blog =
sql "select id, name, title, description, owner, createdAt, modifiedAt, modifiedBy
from Blog
where id = @id"