本文整理汇总了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)))
;
}
示例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>();
}
示例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));
}
示例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()
;
}
示例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);
}
}
示例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));
}
示例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));
}
示例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));
}
示例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);
}
}
示例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());
}
示例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>();
}
示例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));
}
示例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));
}
示例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);
});
}
示例15: MapperGameImport
private void MapperGameImport(IMapperConfiguration map)
{
map.CreateMap<Game, GameDto>().ReverseMap();
}