The trick is very simple: you just need to surround it by a VersionCountDisabler
Here is two examples:
using(new VersionCountDisabler()) { var model = sitecoreService.GetItem("/sitecore/content/home"); }
using(new VersionCountDisabler()) { var model = myItem.CastYou can find it in the official documentation but this isn't a very well-known feature: http://www.glass.lu/Mapper/Sc/Documentation/VersionCountDisabler(item, isLazy, inferType); }
In bonus, here is the way to know if you are in a VersionCountDisabler mode in your code. This is usefull if you wrap the code with a custom method as I do.
bool isInVersionCountDisabler = (Switcher.CurrentValue == VersionCountState.Disabled);
Truely a very good article on how to handle the future technology. After reading your post,thanks for taking the time to discuss this content.
ReplyDeleteDot Net Training in Chennai ECR
This comment has been removed by a blog administrator.
ReplyDelete