Has anyone had success creating CSLA objects from within F#? In particular I'm having difficulty getting the object to correctly access the RegisterProperty in the base object. see code below (the indentations are correct in my code, it just doesn't format real well on this page.)
type CslaTestObj() = inherit ReadOnlyBase<CslaTestObj>()
static let IdProperty = ReadOnlyBase<CslaTestObj>.RegisterProperty(new PropertyInfo<int>("Id"))
member m.Id with get() = m.ReadProperty(IdProperty) |> unbox
This code results in a TypeInitializationException. It doesn't even find the RegisterProperty method even though intellisense says it's matched. I suspect it's not liking the way I'm scoping the RegisterProperty with the base<t> but I can't find any other way to get it to compile.
If you have a working object, I would love to see it. Thanks!
I'll answer my own question. You need to declare the IdProperty as a static member, not a static let.
static member IdProperty = ReadOnlyBase<CslaTestObj>.RegisterProperty(new PropertyInfo<int>("Id"))
Now the problem I'm having is that F# initializes statics as used instead of upon object creation. CSLA requires that the static be initialized upon creation, not afterwards if I'm reading my error correctly. I can't seem to find a way to kick off static initialization manually such as a static constructor.
Copyright (c) Marimer LLC