当前位置: 首页>>代码示例>>C#>>正文


C# IMapperConfiguration.CreateMap方法代码示例

本文整理汇总了C#中IMapperConfiguration.CreateMap方法的典型用法代码示例。如果您正苦于以下问题:C# IMapperConfiguration.CreateMap方法的具体用法?C# IMapperConfiguration.CreateMap怎么用?C# IMapperConfiguration.CreateMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMapperConfiguration的用法示例。


在下文中一共展示了IMapperConfiguration.CreateMap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TeamMapping

        private static void TeamMapping(IMapperConfiguration cfg)
        {
            cfg.CreateMap<TeamPlayerEntity, TeamPlayer>()
                .ForMember(
                    dest => dest.Type,
                    opts => opts.MapFrom(src => src.PlayerType));

            cfg.CreateMap<TeamEntity, Team>()
            .ForMember(
                dest => dest.ClubId,
                opts => opts.MapFrom(src => Constants.OwnClubId))
            .ForMember(
                dest => dest.Competition,
                opts => opts.MapFrom(src => Constants.NormalizeCompetition(src.Competition)))
            .ForMember(
                dest => dest.DivisionName,
                opts => opts.MapFrom(src => src.ReeksNummer + src.ReeksCode))
            .ForMember(
                dest => dest.Frenoy,
                opts => opts.MapFrom(src => new FrenoyTeamLinks
                {
                    DivisionId = src.FrenoyDivisionId,
                    LinkId = src.LinkId,
                    TeamId = src.FrenoyTeamId
                }))
            .ForMember(
                dest => dest.Players,
                opts => opts.MapFrom(src => src.Players))
            .ForMember(
                dest => dest.Opponents,
                opts => opts.MapFrom(src => MapAllTeams(src)))
            ;
        }
开发者ID:TTCErembodegem,项目名称:TTC-React-Back,代码行数:33,代码来源:AutoMapperConfig.cs

示例2: Initialize

        public static void Initialize(IMapperConfiguration mapperConfig)
        {
            mapperConfig.CreateMap<Campaign, CampaignDto>();
            mapperConfig.CreateMap<Picture, PictureDto>();
            mapperConfig.CreateMap<Style, StyleDto>();
            mapperConfig.CreateMap<Painter, PainterDto>();

            mapperConfig.CreateMap<DataAccess.CampaignDto, Domain.Campaign>();
        }
开发者ID:ReaderOfDream,项目名称:GuessThePicture,代码行数:9,代码来源:AutomapperConfig.cs

示例3: ConfigureMaps

        public static void ConfigureMaps(IMapperConfiguration cfg)
        {
            cfg.CreateMap< AuthLoginInfo, AuthLoginInfoPoco>()
            .ForMember(s => s.UserName, m => m.MapFrom(s => s.UserName))
            .ForMember(s => s.PasswordSalt, m => m.MapFrom(s => s.PasswordSalt))
            .ForMember(s => s.HashedPassword, m => m.MapFrom(s => s.HashedPassword));

              cfg.CreateMap<AuthLoginInfoPoco, AuthLoginInfo>()
            .ForMember(s => s.UserName, m => m.MapFrom(s => s.UserName))
            .ForMember(s => s.PasswordSalt, m => m.MapFrom(s => s.PasswordSalt))
            .ForMember(s => s.HashedPassword, m => m.MapFrom(s => s.HashedPassword));
        }
开发者ID:barbosatek,项目名称:Softmex,代码行数:12,代码来源:ObjectMapper.cs

示例4: ReportMapping

        private static void ReportMapping(IMapperConfiguration cfg)
        {
            cfg.CreateMap<MatchCommentEntity, MatchComment>().ReverseMap();
            cfg.CreateMap<MatchPlayerEntity, MatchPlayer>().ReverseMap();

            cfg.CreateMap<MatchGameEntity, MatchGame>()
                .ForMember(d => d.Outcome, o => o.MapFrom(src => src.WalkOver == WalkOver.None ? MatchOutcome.NotYetPlayed : MatchOutcome.WalkOver))
                .ForMember(
                    dest => dest.OutPlayerSets,
                    opts => opts.MapFrom(src => src.AwayPlayerSets))
                .ForMember(
                    dest => dest.OutPlayerUniqueIndex,
                    opts => opts.MapFrom(src => src.AwayPlayerUniqueIndex))
                .ReverseMap()
                ;
        }
开发者ID:TTCErembodegem,项目名称:TTC-React-Back,代码行数:16,代码来源:AutoMapperConfig.cs

示例5: LoadStandardMappings

        private static void LoadStandardMappings(IMapperConfiguration mapperConfiguration, IEnumerable<Type> types)
        {
            var maps = types
                .SelectMany(t => t.GetInterfaces(), (t, i) => new { t, i })
                .Where(type => type.i.IsGenericType &&
                               type.i.GetGenericTypeDefinition() == typeof(IMapFrom<>) &&
                               !type.t.IsAbstract &&
                               !type.t.IsInterface)
                .Select(type => new { Source = type.i.GetGenericArguments()[0], Destination = type.t });

            foreach (var map in maps)
            {
                mapperConfiguration.CreateMap(map.Source, map.Destination);
                mapperConfiguration.CreateMap(map.Destination, map.Source);
            }
        }
开发者ID:vassildinev,项目名称:ASP.NET-MVC,代码行数:16,代码来源:AutoMapperConfig.cs

示例6: ConfigureMaps

        public static void ConfigureMaps(IMapperConfiguration cfg)
        {
            cfg.CreateMap<AuthLoginRequest, AuthLoginInfoPoco>()
            .ForMember(s => s.PlainPassword, m => m.MapFrom(s => s.PlainPassword))
            .ForMember(s => s.UserName, m => m.MapFrom(s => s.UserName));

              cfg.CreateMap<AuthLoginInfoPoco, AuthLoginRequest>()
            .ForMember(s => s.PlainPassword, m => m.MapFrom(s => s.PlainPassword))
            .ForMember(s => s.UserName, m => m.MapFrom(s => s.UserName));

              cfg.CreateMap<AuthLoginResponse, AuthLoginRequest>()
            .ForMember(s => s.UserName, m => m.MapFrom(s => s.UserName))
            .ForMember(s => s.PlainPassword, m => m.MapFrom(s => s.PlainPassword));

              cfg.CreateMap<AuthLoginRequest, AuthLoginResponse>()
            .ForMember(s => s.UserName, m => m.MapFrom(s => s.UserName))
            .ForMember(s => s.PlainPassword, m => m.MapFrom(s => s.PlainPassword));
        }
开发者ID:barbosatek,项目名称:Softmex,代码行数:18,代码来源:ObjectMapper.cs

示例7: CreateMappings

 public override void CreateMappings(IMapperConfiguration configuration)
 {
     configuration.CreateMap<Organisation, OrganisationDetailsModel>()
         .ForMember(x => x.Owner, opt => opt.MapFrom(x => x.Owner.Email))
         .ForMember(
             x => x.Tests,
             opt => opt.MapFrom(x => x.Tests))
         .ForMember(x => x.Users, opt => opt.MapFrom(x => x.Users));
 }
开发者ID:damy90,项目名称:AvalancheAllerts,代码行数:9,代码来源:OrganisationDetailsModel.cs

示例8: CreateMappings

 public void CreateMappings(IMapperConfiguration configuration)
 {
     configuration.CreateMap<User, UserInfoViewModel>()
         .ForMember(
             self => self.QuizzesCreated,
             opt => opt.MapFrom(model => model.QuizzesCreated.Count))
         .ForMember(
             self => self.QuizzesTaken,
             opt => opt.MapFrom(model => model.SolutionsSubmited.Count));
 }
开发者ID:kidroca,项目名称:project-quiz-mvc,代码行数:10,代码来源:UserInfoViewModel.cs

示例9: LoadStandardMappings

        private static void LoadStandardMappings(IEnumerable<Type> types, IMapperConfiguration mapperConfiguration)
        {
            var maps = (from t in types
                        from i in t.GetInterfaces()
                        where i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IMapFrom<>) &&
                              !t.IsAbstract &&
                              !t.IsInterface
                        select new
                        {
                            Source = i.GetGenericArguments()[0],
                            Destination = t
                        }).ToArray();

            foreach (var map in maps)
            {
                mapperConfiguration.CreateMap(map.Source, map.Destination);
                mapperConfiguration.CreateMap(map.Destination, map.Source);
            }
        }
开发者ID:antonpopov,项目名称:Final-Project,代码行数:19,代码来源:AutoMapperConfig.cs

示例10: Configure

 public void Configure(IMapperConfiguration mapperConfiguration)
 {
     mapperConfiguration.CreateMap<NewTask, Data.Entities.Task>()
         .ForMember(opt => opt.Version, x => x.Ignore())
         .ForMember(opt => opt.CreatedBy, x => x.Ignore())
         .ForMember(opt => opt.TaskId, x => x.Ignore())
         .ForMember(opt => opt.CreatedDate, x => x.Ignore())
         .ForMember(opt => opt.CompletedDate, x => x.Ignore())
         .ForMember(opt => opt.Status, x => x.Ignore())
         .ForMember(opt => opt.Users, x => x.Ignore());
 }
开发者ID:Ladex,项目名称:webapi,代码行数:11,代码来源:NewTaskToTaskEntityAutoMappingTypeConfiguration.cs

示例11: Configure

 //методы
 public static void Configure(IMapperConfiguration configuration)
 {
     configuration.CreateMap<SignalBounce<Guid>, SignalBounceGuid>();
     configuration.CreateMap<SignalDispatchBase<Guid>, SignalDispatchBaseGuid>();
     configuration.CreateMap<SubjectDispatch<Guid>, SubjectDispatchGuid>();
     configuration.CreateMap<UserCategorySettings<Guid>, UserCategorySettingsGuid>();
     configuration.CreateMap<UserDeliveryTypeSettings<Guid>, UserDeliveryTypeSettingsGuid>();
     configuration.CreateMap<UserReceivePeriod<Guid>, UserReceivePeriodGuid>();
     configuration.CreateMap<UserTopicSettings<Guid>, UserTopicSettingsGuid>();
 }
开发者ID:RodionKulin,项目名称:SignaloBot,代码行数:11,代码来源:MapperUtility.cs

示例12: ConfigureUserMapping

 private static void ConfigureUserMapping(IMapperConfiguration cfg)
 {
     cfg.CreateMap<UserToRegisterViewModel, User>();
     cfg.CreateMap<UserToLoginViewModel, User>();
     cfg.CreateMap<UserToActivateViewModel, User>();
     cfg.CreateMap<UserToRemindPasswordViewModel, User>();
     cfg.CreateMap<UserToSendActivationCodeViewModel, User>();
     cfg.CreateMap<UserToSendRemindPasswordRequestViewModel, User>();
     cfg.CreateMap<User, User>().ForAllMembers(opt => opt.Condition(c => !c.IsSourceValueNull));
 }
开发者ID:tjel,项目名称:infpro-8,代码行数:10,代码来源:AutoMapperConfiguration.cs

示例13: LoadReverseMappings

        private static void LoadReverseMappings(IEnumerable<Type> types, IMapperConfiguration mapperConfiguration)
        {
            var maps = types
                .Where(t => !t.IsInterface && !t.IsAbstract && t.GetInterfaces()
                    .Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IMapTo<>)))
                .Select(t => new
                {
                    Source = t,
                    Destination = t.GetInterfaces()
                                .Where(i => i.GetGenericTypeDefinition() == typeof(IMapTo<>))
                                .FirstOrDefault()
                                .GetGenericArguments()[0]
                })
                .ToList();

            maps.ForEach(m => mapperConfiguration.CreateMap(m.Source, m.Destination));
        }
开发者ID:simeonpp,项目名称:Trip-Destination,代码行数:17,代码来源:AutoMapperConfig.cs

示例14: MatchMapping

        private static void MatchMapping(IMapperConfiguration cfg)
        {
            cfg.CreateMap<MatchEntity, OtherMatch>()
                .ForMember(
                    dest => dest.Home,
                    opts => opts.MapFrom(src => new OpposingTeam
                    {
                        ClubId = src.HomeClubId,
                        TeamCode = src.HomeTeamCode
                    }))
                .ForMember(
                    dest => dest.Away,
                    opts => opts.MapFrom(src => new OpposingTeam
                    {
                        ClubId = src.AwayClubId,
                        TeamCode = src.AwayTeamCode
                    }))
                .ForMember(
                    dest => dest.IsPlayed,
                    opts => opts.MapFrom(src =>
                        GetScoreType(src) != MatchOutcome.NotYetPlayed &&
                        GetScoreType(src) != MatchOutcome.BeingPlayed))
                .ForMember(
                    dest => dest.ScoreType,
                    opts => opts.MapFrom(src => GetScoreType(src)))
                .ForMember(
                    dest => dest.Score,
                    opts => opts.MapFrom(src => !src.WalkOver && src.HomeScore.HasValue ? new MatchScore(src.HomeScore.Value, src.AwayScore.Value) : null))

                .AfterMap((matchEntity, match) =>
                {
                    //SetMatchPlayerAliases(match);
                    //ChangeMeaningOfHomePlayer(match);
                    SetIndividualMatchesOutcome(match.Games, null);
                });

            cfg.CreateMap<MatchEntity, Match>()
                .ForMember(
                    dest => dest.TeamId,
                    opts => opts.MapFrom(src => src.HomeTeamId.HasValue ? src.HomeTeamId : src.AwayTeamId))
                .ForMember(
                    dest => dest.Opponent,
                    opts => opts.MapFrom(src => new OpposingTeam
                    {
                        ClubId = src.HomeTeamId.HasValue ? src.AwayClubId : src.HomeClubId,
                        TeamCode = src.HomeTeamId.HasValue ? src.AwayTeamCode : src.HomeTeamCode
                    }))
                .ForMember(
                    dest => dest.IsPlayed,
                    opts => opts.MapFrom(src =>
                        GetScoreType(src) != MatchOutcome.NotYetPlayed &&
                        GetScoreType(src) != MatchOutcome.BeingPlayed))
                .ForMember(
                    dest => dest.ScoreType,
                    opts => opts.MapFrom(src => GetScoreType(src)))
                .ForMember(
                    dest => dest.Score,
                    opts => opts.MapFrom(src => !src.WalkOver && src.HomeScore.HasValue ? new MatchScore(src.HomeScore.Value, src.AwayScore.Value) : null))

                .AfterMap((matchEntity, match) =>
                {
                    SetMatchPlayerAliases(match);
                    ChangeMeaningOfHomePlayer(match);
                    SetIndividualMatchesOutcome(match.Games, match.IsHomeMatch);
                });
        }
开发者ID:TTCErembodegem,项目名称:TTC-React-Back,代码行数:66,代码来源:AutoMapperConfig.cs

示例15: MapperGameImport

 private void MapperGameImport(IMapperConfiguration map)
 {
     map.CreateMap<Game, GameDto>().ReverseMap();
 }
开发者ID:pandazzurro,项目名称:uPlayAgain,代码行数:4,代码来源:ImportGameViewModel.cs


注:本文中的IMapperConfiguration.CreateMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。