How to pass the ViewModel property as a model for partial viewing?

I have a ViewModel called LogViewModel in which I have 3 properties as shown below.

public class LogViewModel
{
    public IEnumerable<Log> Logs { get; private set; }
    public PaginationHelper Pagination { get; set; }
    public LogFilter Filter { get; set; }
}

LogViewModel is passed to View as Model. Now I need to pass the LogFilter (with data) in a partial view, for example:

@Html.Partial("_LogsFilter", Model.Filter)

I tried many methods, but always get the same error:

The model element passed to the dictionary is of type 'Infrastructure.Presentation.Desk.ViewModels.LogViewModel', but for this dictionary a model element of type 'Infrastructure.Presentation.Desk.Models.LogFilter' is required.

Any thoughts?

+4
source share
2 answers

Filter null, , LogViewModel, LogFilter.

, , Filter - :

@Html.Partial("_LogsFilter", Model.Filter ?? new LogFilter())
+7

" LogFilter". , LogFilter, " LogViewModel". , .

0

All Articles