S
Scott Rymer
I stumbled upon Peter Kellner's ObjectDataSource Generation for Profiles
which generates a Membership class to use in ASP.NET. The only problem is,
it's in C# and I need it in VB to use it in my project. Can anyone help me
convert this into VB.NET? In particular, I'm trying to convert this code:
Comparison<MembershipUserWrapperForMP> comparison = null;
switch (sortDataBase)
{
case "FirstName":
comparison = new
Comparison<MembershipUserWrapperForMP>(
delegate(MembershipUserWrapperForMP lhs,
MembershipUserWrapperForMP rhs)
{
if (lhs.FirstName == null || rhs.FirstName ==
null)
{
return 1;
}
else
{
return
lhs.FirstName.CompareTo(rhs.FirstName);
}
}
);
break;
case "LastName":
comparison = new
Comparison<MembershipUserWrapperForMP>(
delegate(MembershipUserWrapperForMP lhs,
MembershipUserWrapperForMP rhs)
{
if (lhs.LastName == null || rhs.LastName ==
null)
{
return 1;
}
else
{
return lhs.LastName.CompareTo(rhs.LastName);
}
}
);
break;
I think I'm almost there with:
Case "FirstName"
Dim comparison As Comparison(Of
MembershipUserWrapperForMP)(Function(ByVal lhs As
MembershipUserWrapperForMP, ByVal rhs As MembershipUserWrapperForMP)
If (lhs.FirstName Is Nothing) OrElse (rhs.FirstName Is Nothing)
Then Return 1 Else Return lhs.FirstName.CompareTo(rhs.LastName)
Case "Last Name"
etc...
but I'm getting Expresssion Expected at the end of the Dim line and lhs and
rhs not declared in the If line...
-Scott
which generates a Membership class to use in ASP.NET. The only problem is,
it's in C# and I need it in VB to use it in my project. Can anyone help me
convert this into VB.NET? In particular, I'm trying to convert this code:
Comparison<MembershipUserWrapperForMP> comparison = null;
switch (sortDataBase)
{
case "FirstName":
comparison = new
Comparison<MembershipUserWrapperForMP>(
delegate(MembershipUserWrapperForMP lhs,
MembershipUserWrapperForMP rhs)
{
if (lhs.FirstName == null || rhs.FirstName ==
null)
{
return 1;
}
else
{
return
lhs.FirstName.CompareTo(rhs.FirstName);
}
}
);
break;
case "LastName":
comparison = new
Comparison<MembershipUserWrapperForMP>(
delegate(MembershipUserWrapperForMP lhs,
MembershipUserWrapperForMP rhs)
{
if (lhs.LastName == null || rhs.LastName ==
null)
{
return 1;
}
else
{
return lhs.LastName.CompareTo(rhs.LastName);
}
}
);
break;
I think I'm almost there with:
Case "FirstName"
Dim comparison As Comparison(Of
MembershipUserWrapperForMP)(Function(ByVal lhs As
MembershipUserWrapperForMP, ByVal rhs As MembershipUserWrapperForMP)
If (lhs.FirstName Is Nothing) OrElse (rhs.FirstName Is Nothing)
Then Return 1 Else Return lhs.FirstName.CompareTo(rhs.LastName)
Case "Last Name"
etc...
but I'm getting Expresssion Expected at the end of the Dim line and lhs and
rhs not declared in the If line...
-Scott