Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 24 2018 16:41

    leekelleher on develop

    Migration to UMCO - Updated th… (compare)

  • Jan 24 2018 16:40
    leekelleher edited #234
  • Jan 24 2018 16:40
    leekelleher edited #234
  • Jan 24 2018 16:40
    leekelleher edited #234
  • Jan 24 2018 16:22
    leekelleher edited #234
  • Jan 24 2018 16:20
    leekelleher edited #234
  • Jan 24 2018 16:03
    leekelleher labeled #234
  • Jan 24 2018 16:03
    leekelleher assigned #234
  • Jan 24 2018 16:03
    leekelleher opened #234
  • Jan 24 2018 15:39
    leekelleher unassigned #195
  • Jan 24 2018 15:39
    leekelleher unassigned #188
  • Jan 24 2018 15:39
    leekelleher unassigned #177
  • Jan 24 2018 15:39
    leekelleher unassigned #176
  • Jan 24 2018 15:39
    leekelleher unassigned #138
  • Jan 24 2018 15:39
    leekelleher unassigned #111
  • Jan 24 2018 15:39
    leekelleher unassigned #67
  • Jan 24 2018 15:39
    leekelleher unassigned #61
  • Jan 24 2018 15:39
    leekelleher unassigned #59
  • Jan 24 2018 15:39
    leekelleher unassigned #53
  • Jan 24 2018 15:39
    leekelleher unassigned #49
Lee Kelleher
@leekelleher
@JimBobSquarePants Oh, congrats with the pregnancy news! Exciting times ahead! :-D
James Jackson-South
@JimBobSquarePants

@leekelleher Thanks! Yeah, we need to get those docs sorted. Been working on something the last 24 hours I wanted to show you sometime... Another mapping approach, convention based, would love your input.

https://twitter.com/James_M_South/status/890594763442765824

Lee Kelleher
@leekelleher
Ooo interesting! Of course, raises obvious questions about overlapping with Ditto and/or other Umbraco mappers ... but I'm all for innovation & exploring ideas! :-D
So would this keep the mapping separate from the POCO?
Lee Kelleher
@leekelleher
but yeah, totally happy to give input on it :+1:
Jamie Pollock
@jamiepollock
Random thought, this is unrelated to @JimBobSquarePants' new way workflow always wondered how a Fluent mapper would work out. Between this, Ditto & ModelsBuilder the bases are pretty covered.
James Jackson-South
@JimBobSquarePants
@leekelleher Thanks! appreciate it. I wanted to experiment with something different as over time I've grown less comfortable with attribute decoration and wanted to keep the POCO's as such. I'll upload some code today.
Collyn Philleo
@cphilleo
@JimBobSquarePants I too prefer to keep mappings separate from POCOs. A couple years ago I create a mapper that looks pretty similar to yours that we use internally at my agency. The documentation is sorely lacking, but I've put it up on GitHub . I based it on NHibernate/Fluent.NHibernate. It does a few cool things and has a pseudo lazy loading mechanism. (It's really on-demand I guess, but I'd love to go back and do it using Rosyln to create dynamic proxies or something similar). Anyway, take a look and give any feedback if you like, you might find something useful in there. https://github.com/rhythmagency/rhythm.populate
Lee Kelleher
@leekelleher
@mattbrailsford @JimBobSquarePants Just a heads up that I'm prep'ing for the v0.11 release. I've written up the release notes, etc.
Lee Kelleher
@leekelleher
Matt Brailsford
@mattbrailsford
🎉
Matt Brailsford
@mattbrailsford
@JimBobSquarePants I must admit, I'm starting to think the same a little about the attributes (though my dislike has grown more so coming from UI-O-Matic)
interested to see where you go with your mapping strategy
Lee Kelleher
@leekelleher
re: attributes - yup, I've had similar thoughts, especially when some of my "POCOs" get too far decorated.
@mattbrailsford Did you have an example of using AutoMapper to map IPublishedContent to POCO? (maybe from your CG17 talk?)
I'm struggling to find a nice example of AutoMapper usage to compare & contrast with UmbMapper's API (and Zone's "Umbraco Mapper" too)
Matt Brailsford
@mattbrailsford
using System;
using System.Linq;
using System.Web;
using AutoMapper;
using Codecabin.App.Extensions;
using Codecabin.App.ValueConveters;
using Codecabin.App.ViewModels;
using Skybrud.Social.Twitter.Objects;
using Umbraco.Web.PublishedContentModels;

namespace Codecabin.App
{
    internal class AutoMapperConfig
    {
        public static void RegisterMappings()
        {
            // Activity
            Mapper.CreateMap<Social, SocialViewModel>()
                .ForMember(x => x.Statuses, s => s.Ignore());

            Mapper.CreateMap<TwitterStatusMessage, StatusViewModel>()
                .ForMember(x => x.Avatar, s => s.MapFrom(x => x.User.ProfileImageUrlHttps))
                .ForMember(x => x.Name, s => s.MapFrom(x => x.User.Name))
                .ForMember(x => x.ScreenName, s => s.MapFrom(x => x.User.ScreenName))
                .ForMember(x => x.Html, s => s.MapFrom(x => x.LinkifiedText()))
                .ForMember(x => x.CreateDate, s => s.MapFrom(x => x.CreatedAt));

            // Attendees
            Mapper.CreateMap<Attendees, AttendeesViewModel>()
                .ForMember(x => x.Attendees, s => s.MapFrom(x => x.Children.OfType<Attendee>()));

            Mapper.CreateMap<Attendee, AttendeeViewModel>()
                .ForMember(x => x.Avatar, s => s.MapFrom(x => HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + x.Avatar + "?preset=avatar"));

            // Schedule
            Mapper.CreateMap<Schedule, ScheduleViewModel>()
                .ForMember(x => x.Days, s => s.MapFrom(x => x.Children.OfType<Day>()));

            Mapper.CreateMap<Day, DayViewModel>()
                .ForMember(x => x.Activities, s => s.MapFrom(x => x.Children.OfType<Activity>()));

            Mapper.CreateMap<Activity, ActivityViewModel>();

            // Info
            Mapper.CreateMap<Info, InfoViewModel>()
                .ForMember(x => x.Data, s => s.MapFrom(x => x));

            Mapper.CreateMap<Info, InfoDataViewModel>();

            Mapper.CreateMap<LatLng, LatLngViewModel>();
        }
    }
}
This was from the codecabin app just mapping some models builder models to view models
ForMember => MapFrom gets a bit verbose, so @JimBobSquarePants solution is a bit cleaner in that respect
I can't say any of this is necessarily best practice though, just what I got working
Matt Brailsford
@mattbrailsford
I just shared this with @leekelleher and thought it might be interesting to others here https://www.youtube.com/watch?v=AQGk8WnMpAY
James Jackson-South
@JimBobSquarePants
@leekelleher When did we add passing an instance to map to to the API? That makes things.... Difficult re proxying. We end up replacing the instance that gets passed.
Oh also re #223 You can drop the HtmlString converter. As soon as you use IHtmlString as your property type GetPropertyValue will already map it.
Matt Brailsford
@mattbrailsford
Hasn't the API always supported mapping to an existing object instance?
James Jackson-South
@JimBobSquarePants
Dunno... Never spotted it before. Essentially though we can't proxy a passed instance only a new one.
Lee Kelleher
@leekelleher
@JimBobSquarePants re: HtmlString, sure thing :+1:
with passing an instance in... it's been there a pretty long time
James Jackson-South
@JimBobSquarePants
I got it all working anyway. It just won't attempt to lazy map an existing instance
Phong Bui
@loveunCG
hello
Norbert Haberl
@nhaberl
Guys, is Ditto still the mapper to use ? Or better to use umbMapper or UmbracoMapper ?
Lee Kelleher
@leekelleher

Hi @nhaberl - ultimately the choice is yours, like with soft drinks, there's plenty of choice... Pepsi, Coke, 7-Up :smile:
We're still supporting Ditto and it still has consistent NuGet downloads, around 44/day - so not crazy high demand, but enough to know people are still using it.

Personally I'm using ModelsBuilder more these days. Mostly because I don't need overly complex view-models. It's great to have Ditto in my utility belt, just in case though. :smile:

Norbert Haberl
@nhaberl
I know I know ... thanks
Just wanted to confirm that Ditto is alive :)
Lee Kelleher
@leekelleher
No worries :smile: Ditto is alive. :+1: