views:

143

answers:

1

Hi I have been looking at certain tutorials on sharparchitecture and trying to no avail (the online convertors don't seem to be able to do this):

     private Action<AutoMappingExpressions> GetSetup()
 {
  return c =>
  {
   c.FindIdentity = type => type.Name == "Id";
  };
 }

 private Action<IConventionFinder> GetConventions()
 {
  return c =>
  {
   c.Add<MVCTemp.Data.NHibernateMaps.Conventions.ForeignKeyConvention>();
   c.Add<MVCTemp.Data.NHibernateMaps.Conventions.HasManyConvention>();
   c.Add<MVCTemp.Data.NHibernateMaps.Conventions.HasManyToManyConvention>();
   c.Add<MVCTemp.Data.NHibernateMaps.Conventions.ManyToManyTableNameConvention>();
   c.Add<MVCTemp.Data.NHibernateMaps.Conventions.PrimaryKeyConvention>();
   c.Add<MVCTemp.Data.NHibernateMaps.Conventions.ReferenceConvention>();
   c.Add<MVCTemp.Data.NHibernateMaps.Conventions.TableNameConvention>();
  };
 }

Any help would be greatly appreciated.

+4  A: 

I assume that you're trying to convert this to VB.Net.

Until Visual Basic 2010 (currently in beta), it's not possible.

Lambda expressions in VB.Net 2008 can only hold a single expression.

However, you could create Shared helper functions that do the work and return them.

For example: (In VB)

Function GetConventions() As Action(Of IConventionFinder) 
    Return AddressOf GetConventionsHelper
End Function

Shared Sub GetConventionsHelper(c As IConventionFinder)
    c.Add(Of MVCTemp.Data.NHibernateMaps.Conventions.ForeignKeyConvention)()
    c.Add(Of MVCTemp.Data.NHibernateMaps.Conventions.HasManyConvention)()
    c.Add(Of MVCTemp.Data.NHibernateMaps.Conventions.HasManyToManyConvention)()
    c.Add(Of MVCTemp.Data.NHibernateMaps.Conventions.ManyToManyTableNameConvention)()
    c.Add(Of MVCTemp.Data.NHibernateMaps.Conventions.PrimaryKeyConvention)()
    c.Add(Of MVCTemp.Data.NHibernateMaps.Conventions.ReferenceConvention)()
    c.Add(Of MVCTemp.Data.NHibernateMaps.Conventions.TableNameConvention)()
End Sub
SLaks
Sorry for the vague question yes I am trying to convert it to vb.net
Monkeeman69