Is there a way for two entities with foreign key relations to be represented in class files keeping in mind that F# has to have the files in order?
Say I have a User and the user has books.
type User(books:seq<Book>) :
mutable _books = books
member public x.Books
with get() = _books
and set bookList = _books <- bookList
type Books(parentUser:User) :
mutable _parentUser = parentUser
member public x.ParentUser
with get() = _parentUser
and set newParentUser = _parentUser <- newParentUser
Now because of how F# works, this won’t compile since it’s basically a circular reference. User comes before Book therefore it doesn’t know what a book is. If I move the book class up, the opposite is true.
Is there a way around the whole “Compile in order” way that F# works or do I need to set up entities and relations in another language?
You’ll need to define both types in the same file using
type User ... and Books. See the section on Mutually Recursive Types on MSDN.