Developer forum

Forum » Development » Convert Item into ItemVIewModel

Convert Item into ItemVIewModel

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

What is the best approach to convert an Item into an ItemViewModel?

Is this even possible?

Thank you,
Adrian


Replies

 
Vladimir Shushunov Dynamicweb Employee
Vladimir Shushunov
Reply

Hi Adrian,

I would suggest to use ItemTypeEditor:

var editor = new ItemTypeEditor(); 
editor.ItemType = itemType;
if(editor.GetViewModelValue(itemId) is ItemViewModel model)
{...}

Best regards,
Vladimir

 

 

You must be logged in to post in the forum