Property Definition Type map it to IEnumberable<T>

Vote:
 

Am getting below error; while creating the block, pleas see the below details and help me in this regard. Thanks

Error: Type 'System.Collections.Generic.IEnumerable`1[[Project.Web.ViewModels.Blocks.EmpViewModel, Project.Web, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null]]' could not be mapped to a PropertyDefinitionType

---------------------------------------

EmpClass:-

My EmpBlockViewModel below

---------------------------------------

public class Emp
{
     public string EmpName { get; set; }
     public int EmpNo  { get; set; }
     public double EmpSal { get; set; }
}

---------------------------------------

EmpDetailsBlock:-

---------------------------------------

[Display(Order = 110,
     GroupName = SystemTabNames.Content,
     Name = "Emp Details list",
     Description = "The block will display all the Employess Details.")]
[CultureSpecific]
public virtual IEnumerable EmpDetailsList { get; set; } 

---------------------------------------

EmpDetailsBlockController:-

---------------------------------------

public class EmpDetailsBlockController : EmpBlockController
{
public override ActionResult Index(EmpDetailsBlock currentBlock)
{
     currentBlock = new EmpDetailsBlock();
     currentBlock.EmpDetailsList = ListofEmployees; // ListofEmployees is added.

     return PartialView("~/Views/Blocks/EmpBlock/Index.cshtml", currentBlock);
}

---------------------------------------

EmpBlock View:--

---------------------------------------

@model IEnumerable





@if (Model.EmpDetailsList != null)
{

Emp Details!!!


}



@if (Model.EmpDetailsList != null)
{







@foreach (EmpBlockViewModel d in Model.EmpDetailsList)
{





}
EmpNameEmpNoEmpSal
@d.EmpName@d.EmpNo@d.EmpSal

}


---------------------------------------

#181550
Edited, Aug 24, 2017 10:11
Vote:
 

This does not seem the correct definition for list of Emp, 

public virtual IEnumerable { get; set; } 
try

public virtual IList<Emp> EmpList { get; set; }

 

#181583
Aug 24, 2017 16:03
Vote:
 

I've tried with your suggested option; also tried with List<T>, but no luck.

still am getting the same.

Type 'System.Collections.Generic.IList`1[[Project.Web.ViewModels.Blocks.EmpBlockViewModel, Project.Web, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null]]' could not be mapped to a PropertyDefinitionType

Please help. Thanks

#181585
Edited, Aug 24, 2017 16:20
Vote:
 

have you register the property definition e.g.


[PropertyDefinitionTypePlugIn]
public class EmpListProperty : PropertyListBase<Emp>
{

}

#181586
Aug 24, 2017 16:31
Vote:
 

this is how you will define property in your page type


[EditorDescriptor(EditorDescriptorType = typeof (CollectionEditorDescriptor<Emp>))]
public virtual IList<Emp> EmpList { get; set; }

#181587
Aug 24, 2017 16:34
Vote:
 

Thanks a bunch for your qucik response.

Property Definition, I've not registered and I'm not aware of this.

Could you please tell me or share any knowledge base example link. Thanks once again.

#181588
Aug 24, 2017 16:36
Vote:
 

this is all that you will require

Define a model
public class Emp
{
public string Name { get; set; }
}

Register Property Definition

[PropertyDefinitionTypePlugIn]
public class EmpListProperty : PropertyList<Emp>
{
}

Add handy editor
[EditorDescriptor(EditorDescriptorType = typeof (CollectionEditorDescriptor<Emp>))]
public virtual IList<Emp> Emps { get; set; }

#181589
Aug 24, 2017 16:45
Vote:
 

I've registered the property definition as mentioned below:

using EPiServer.Cms.Shell.UI.ObjectEditing.EditorDescriptors;

using EPiServer.Shell.ObjectEditing;

[EditorDescriptor(EditorDescriptorType = typeof(CollectionEditorDescriptor<EmpBlockViewModel>))]
public virtual IList<EmpBlockViewModel> EmpDetailsList { get; set; }

Unforturnately, I couldn't resolve the error.

Am looking for, EpiServer Application block: To bind the list of values to the block. Thanks

#181590
Edited, Aug 24, 2017 16:49
Ed
Vote:
 

Is anything related to this actually documented anywhere? I'm trying to do something that should be pretty simple, and I'm now a few hours into it, with no help from documentation.

#229012
Oct 06, 2020 18:41
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.