I'm trying to convert the following C# code to VB.NET. The issue is with the lambda expression.
public class UserStore
{
private readonly IDatabaseFactory _databaseFactory;
private DataContext _db;
protected DataContext Db => _db ?? (_db = _databaseFactory.GetDataContext());
public UserStore(IDatabaseFactory databaseFactory)
{
_databaseFactory = databaseFactory;
}
}
The following is what I've converted the code to:
Public Class UserStore
Private ReadOnly _databaseFactory As IDatabaseFactory
Private _db As DataContext
Protected Db As DataContext = Function() As DataContext
If _db Is Nothing Then
_db = _databaseFactory.GetDataContext()
End If
Return _db
End Function
Public Sub New(databaseFactory As IDatabaseFactory)
_databaseFactory = databaseFactory
End Sub
End Class
For some reason, the converted lambda gives the error Lambda expression cannot be converted to 'DataContext' because 'DataContext' is not a delegate type.
Can anybody tell me what I'm doing wrong here?