handling multiple select values in ASP.net MVC with a service layer -


i have many multiple select dropdowns in asp.net mvc application , wondering best way handle transferring values viewmodel model saved database using ef6 (im using db first way create entities). 1 of viewmodels looks this

     public class someviewmodel{        public string[] selectedids        public ienumerable<selectlistitem> selectvalues        //other properties      } 

i decided create partial model class , add selectedids like

public partial class somemodel{  public string[] selectedids  //other properties } 

my model passed service layer

public class someservicelayer{      public int insertsomething(somemodel model){       //do stuff         if (model.selectedids.length != 0){                 model.selectvalues = _context.selectvalues                     .where(b => model.selectedids.contains(b.id.tostring())).tolist();             }      }    } 

it feels wrong have add custom property in partial class model. there better way of handling this? interested know


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -