I have 2 projects in a solution: a C# class library and an F# library.
The C# library has the following class:
using System;
namespace TestFSharpDataLayer.Domain
{
public class TestData
{
public Guid Id { get; set; }
public string Nickname { get; set; }
public DateTime StartDate { get; set; }
public bool Active { get; set; }
public byte[] Fingerprint { get; set; }
public char Prefix { get; set; }
public int Multiplier { get; set; }
}
}
I'm writing a module in the F# library to get data from a MSSQL database, and I want to make my List function to return an array of TestData
objects. I'm using SQLProvider in the F# library.
Module code:
namespace TestFSharpDataLayer.Infrastructure
module PersonasRepository =
open FSharp.Data.Sql
open FSharp.Data.Sql.Common
open TestFSharpDataLayer.Domain
type private sql = SqlDataProvider<DatabaseProviderTypes.MSSQLSERVER,"server=(localdb)\MSSQLLocalDB;Database=Test;Trusted_Connection=true;">
let private context = sql.GetDataContext()
let private ListarInternal (pagina : int) =
query {
for c in context.Dbo.TestData do
sortBy (c.GetColumn "Nickname")
skip ((pagina - 1) * 15)
take 15
select c
}
|> Seq.map EntityToTestData
|> Seq.toArray
let private EntityToTestData (entity : sql.dataContext.``dbo.test_dataEntity``) : TestData =
new TestData(Id = entity["Id"], Nickname = entity["Nickname"])
let Listar (pagina : int) =
match pagina with
| t when t > 0 -> ListarInternal(pagina)
| _ -> null
Problem is, I can't get the module to recognize the TestData
class. C# library is referenced in the F# library, but the open TestFSharpDataLayer.Domain
sentence is not recognized by Intellisense and it also throws a compile-time error (TestFSharpDataLayer namespace not defined
). Visual Studio shows no warnings.
What am I doing wrong?