I got this msg while using F# query expression : error FS0039: Undefined value or constructor “query”

StackOverflow https://stackoverflow.com/questions/19720207

  •  02-07-2022
  •  | 
  •  

سؤال

let q = <@  seq {
                for i in [1..10] do
                    yield i  
        } |> Seq.head @>

q |> query |> ignore  //error FS0039

I'am using VS2012 and F# core of "ReferenceAssemblies\Microsoft\FSharp\3.0\Runtime\v2.0\FSharp.Core.dll" (version 2.3.0.0) on .NET 3.5 ;

What did I miss here?

هل كانت مفيدة؟

المحلول

I might be wrong (the versioning is a bit confusing) but if you're using F# 3.0 in Visual Studio 2012, then you should be able to use the new query expression syntax instead:

query { for i in 1 .. 10 do
        select i
        head }

This works both in memory and for SQL databases (as well as some type providers). For more information, see the MSDN documentation. If you're using older version (or target framework), then I'd definitely recommend upgrading - the F# 3.0 queries are much more solid and easy to use.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top