Skip to content

The input sequence was empty issue #153

Closed
@jasonweiyi

Description

@jasonweiyi

(I'm not sure this is an issue or I'm missing something in the code)

I'm using SQLProvider to connect to MySQL. And the MySQL database has the table urls with two columns, one is "url:varchar(128)", the other is "length:int".

When I do the following in F#:
let result =
query {
for v in ctxt.[demo].[urls] do
select v.url
}
|> Seq.toArray

I got the correct result:
val result : string [] =
[|"http://www.amazon.com"; "http://www.google.com";
"http://www.microsoft.com"|]

But when I do:

let result =
query {
for v in ctxt.[demo].[urls] do
select v
}
|> Seq.toArray

I got the following error:
System.ArgumentException: The input sequence was empty.
Parameter name: source
at Microsoft.FSharp.Collections.SeqModule.Head[T](IEnumerable1 source) at FSharp.Data.Sql.QueryExpression.QueryExpressionTransformer.convertExpression(SqlExp exp, List1 entityIndex, IDbConnection con, ISqlProvider provider) in F:\GIT\SQLProvider\src\SQLProvider\SqlRuntime.QueryExpression.fs:line 143
at FSharp.Data.Sql.Runtime.QueryImplementation.executeQuery(ISqlDataContext dc, ISqlProvider provider, SqlExp sqlExp, List1 ti) in F:\GIT\SQLProvider\src\SQLProvider\SqlRuntime.Linq.fs:line 36 at FSharp.Data.Sql.Runtime.QueryImplementation.SqlQueryable1.System-Collections-Generic-IEnumerable1-GetEnumerator() in F:\GIT\SQLProvider\src\SQLProvider\SqlRuntime.Linq.fs:line 77 at Microsoft.FSharp.Collections.SeqModule.ToArray[T](IEnumerable1 source)
at <StartupCode$FSI_0051>.$FSI_0051.main@() in C:\jasonw\mbrace-starterkit-fork\azure\HandsOnTutorial\13-accessing-mysql.fsx:line 33
Stopped due to error

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions