Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standard Template Created and Updated date is not mapping in Fluent mapping #412

Open
hsdulawat opened this issue Jun 23, 2020 · 1 comment

Comments

@hsdulawat
Copy link

Hi Mike,
I am using fluent mapping in my Sitecore project. I am using Sitecore 9.3 and Glass mapper 9.3 for my project.
I have created IGlassBase.cs for map standard template items. When I am trying to map Created and Updated Date using fluent mapping both are not working.
My IGlassBase.cs Class is as below:

public interface IGlassBase
{
Guid Id { get; set; }
DateTime CreatedDate { get; set; }
DateTime UpdatedDate { get; set; }
string DisplayName { get; set; }
Language Language { get; set; }
int Version { get; set; }
string Name { get; set; }
string Path { get; set; }
string ContentPath { get; set; }
string FullPath { get; set; }
string Url { get; set; }
string PageUrl { get; set; }
string MediaUrl { get; set; }
IEnumerable BaseTemplateIds { get; set; }
string TemplateName { get; set; }
Guid TemplateId { get; set; }
IGlassBase Parent { get; set; }
IEnumerable Children { get; set; }
}

And I am mapping IGlassBase using Fluent as below:

public class GlassMappings : SitecoreGlassMap
{
public override void Configure()
{
Map(config =>
{
config.AutoMap();
config.Field(f => f.CreatedDate).FieldName("__created");
config.Field(f => f.UpdatedDate).FieldName("__Updated");
config.Info(f => f.DisplayName).InfoType(SitecoreInfoType.DisplayName);
config.Info(f => f.PageUrl).InfoType(SitecoreInfoType.Url).UrlOptions(SitecoreInfoUrlOptions.LanguageEmbeddingNever);
config.Info(f => f.MediaUrl).InfoType(SitecoreInfoType.MediaUrl).UrlOptions(SitecoreInfoMediaUrlOptions.LowercaseUrls);
config.Parent(f => f.Parent);
config.Children(f => f.Children);
});
}
}

I am to get Dispaly Name, URL etc but not able to map Created and Updated Date. It returning me DateTime.min. I have tried below option as well but not success:

  1. Removed AutoMap ()
  2. Put it before the AutoMap()

Please have a look and do the needful.

Thanks & Regards,
Himmat Singh Dulawat

@mogas
Copy link

mogas commented Jun 4, 2021

@mikeedwards83 I'm getting the same issue as described here. Is this still an open issue or is there a quick workaround? (v5.8.177)

Note: It works using attribute mapping [SitecoreField("__Updated")]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants