I am having a small issue converting some C# code to VB.NET. I am working with this online blog: http://refactorthis.wordpress.com/2011/05/31/mock-faking-dbcontext-in-entity-framework-4-1-with-a-generic-repository/
In the part about creating a fake in memory IDBSet, it has the following code:
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return _data.GetEnumerator();
}
IEnumerator<T> IEnumerable<T>.GetEnumerator()
{
return _data.GetEnumerator();
}
Using a code translator renders the following:
Private Function GetEnumerator() As IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
Return _data.GetEnumerator()
End Function
Private Function GetEnumerator() As IEnumerator(Of T) Implements IEnumerable(Of T).GetEnumerator
Return _data.GetEnumerator()
End Function
It appears to me as a correct translation, but DB.Net is complaing with the following error: Private Function GetEnumerator … and Private Function GetEnumerator … cannot overload each other because they differ only by return types. Both are required to implement IDBSet.
Any ideas on how to correctly convert this code?
Since they’re both
Private, just change the name of one of them. The important part is that they implement their respective interface methods. This would work: