将Priject转换为VB.NET后出错(从C#)
我想把这个C#转换成VB.NET将Priject转换为VB.NET后出错(从C#),c#,vb.net,converter,automapper,C#,Vb.net,Converter,Automapper,我想把这个C#转换成VB.NET internal static void CreateMap(AutoMapperService autoMapperService) { Player.CreateMap(autoMapperService); RawStats.CreateMap(autoMapperService); autoMapperService.CreateMap<string, GameTypeEnum>()
internal static void CreateMap(AutoMapperService autoMapperService)
{
Player.CreateMap(autoMapperService);
RawStats.CreateMap(autoMapperService);
autoMapperService.CreateMap<string, GameTypeEnum>()
.ConvertUsing(s => GameTypeConsts.GameTypes
.First(x => x.Value == s).Key);
autoMapperService.CreateMap<string, GameModeEnum>()
.ConvertUsing(s => GameModeConsts.GameModes
.First(x => x.Value == s).Key);
autoMapperService.CreateMap<string, GameSubTypeEnum>()
.ConvertUsing(s => GameSubTypeConsts.GameSubTypes
.First(x => x.Value == s).Key);
CreateMap<Game>(autoMapperService);
CreateMap<IGame>(autoMapperService).As<Game>();
autoMapperService.CreateMap<RecentGamesDto, IEnumerable<IGame>>()
.ConvertUsing(x => x.Games.Select(autoMapperService.Map<GameDto, IGame>));
}
在最后一个VB.NET代码行中,我发现了一个异常:
告诉我缺少item属性
这就是最初的项目:
这是我缺少item属性的函数:
有人能给我一个提示我错过了什么吗
关于我不是100%确定(我的VB.NET技能已经过时了),但我认为问题在于如何将映射
方法作为参数传递给选择
方法。尝试使用:
autoMapperService.CreateMap(属于最近的gamesdto,IEnumerable(属于IGame))()。ConvertUsing(函数(x)x.Games.选择(autoMapperService.Map(属于GameDto,IGame))的地址)
不要这样做。不要转换到VB.NET,你就不会有这个问题。谢谢!这就是我问题的解决办法。
Friend Shared Sub CreateMap(autoMapperService As AutoMapperService)
Player.CreateMap(autoMapperService)
RawStats.CreateMap(autoMapperService)
autoMapperService.CreateMap(Of String, GameTypeEnum).ConvertUsing(Function(s) GameTypeConsts.GameTypes.First(Function(x) x.Value = s).Key)
autoMapperService.CreateMap(Of String, GameModeEnum).ConvertUsing(Function(s) GameModeConsts.GameModes.First(Function(x) x.Value = s).Key)
autoMapperService.CreateMap(Of String, GameSubTypeEnum).ConvertUsing(Function(s) GameSubTypeConsts.GameSubTypes.First(Function(x) x.Value = s).Key)
CreateMap(Of Game)(autoMapperService)
CreateMap(Of IGame)(autoMapperService).[As](Of Game)()
autoMapperService.CreateMap(Of RecentGamesDto, IEnumerable(Of IGame))().ConvertUsing(Function(x) x.Games.Select(autoMapperService.Map(Of GameDto, IGame)))
End Sub