Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

F# - Which ORM to choose?

Tags:

orm

f#

I've just started playing with F#, and was wondering whether there is any recommended ORM's out there, for F#.

In C# I used NHibernate, which seems to be quite hard and ugly to implement in F#. I've also thought about using plain old System.Data.SqlClient, but thats like going back to the stone age...

Any suggestions?

like image 907
ebb Avatar asked Mar 10 '11 20:03

ebb


4 Answers

This may be missing the point (like if this is just for education or fun), but if you already know how to use an ORM in C#, why not just do it in C# as a library and then do the rest of the logic in F#? One of the major selling points for .NET languages is interoperability.

like image 81
CodexArcanum Avatar answered Nov 14 '22 07:11

CodexArcanum


I've been using F# support for LINQ to SQL when working on fssnip.net. It is fine when you need to load, edit, insert entities and it is fine for writing simple queries. It has some nice aspects e.g. you can use splicing to compose parts of a query.

However, the current implementation of F# to LINQ translator doesn't handle complex queries (nested function calls, advanced grouping and joins), so I wrote a few stored procedures. These can be nicely called via generated LINQ objects, but you have to write some SQL.

Alternatively, if you wanted to use the old fashioned SqlClient, you could make it nicer by using the dynamic (?) operator. I wrote about this in this blog post. For simple scenarios, this could be quite good technique, because it is very simple.

like image 8
Tomas Petricek Avatar answered Nov 14 '22 08:11

Tomas Petricek


I've been using LINQ to SQL via the F# PowerPack. I'm using manual mapping (ie. creating my datacontext by hand, creating my POCO classes as well as writing the XML file to define my database layout). It seems to work well in F# from what I've done so far.

like image 1
Frank Hale Avatar answered Nov 14 '22 08:11

Frank Hale


Two options for interacting with databases using F# that might be of use are FSharp.Data.SqlClient and SQLProvider.

like image 1
Simon Morgan Avatar answered Nov 14 '22 08:11

Simon Morgan