Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In the current version, the F# support for LINQ is not as smooth as in C#, but it can be used pretty well. I used F# + LINQ to SQL when implementing <a href="http://www.fssnip.net" rel="nofollow">F# Snippets Web</a> and was able to write almost everything using F#. There are even some nice features that you don't get in C#.</p> <p>The syntax for basic queries is based on quoted sequence expressions:</p> <pre><code>let q = &lt;@ seq { for c in db.Customers do if c.Country = "UK" then yield c.Name } @&gt; </code></pre> <p>A nice thing in F# is that you can use <em>quotation splicing</em> to refactor your code:</p> <pre><code>let ukCustomers = &lt;@ seq { for c in db.Customers do if c.Country = "OK" then yield c } @&gt; // Select names of all UK customers let q = &lt;@ seq { for c in %ukCustomers -&gt; c.Name } </code></pre> <p>Regarding the limitations of F# support:</p> <ul> <li><p>I don't think there are any issues with updates (as implied in the linked question).</p></li> <li><p>Perhaps the largest limitation of the current version is that it has only limited support for nesting of queries (e.g. using <code>Seq.filter</code> inside body of <code>for</code> loop), but that should be fixed in next version of <a href="http://fsharppowerpack.codeplex.com/" rel="nofollow">PowerPack</a> (in fact, if you compile it from source, you may get it already)</p></li> <li><p>If you can choose, I'd recommend using LINQ to SQL instead of LINQ to Entities. LINQ to Entities doesn't work very well with immutable types, so you cannot easily return F# records and F# tuples. Again, this will likely improve in the future (I did some work on this recently and you can find an initial support in F# PowerPack sources)</p></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload