c# - Inner helper with different conditions in foreach loop, how to manage that? -
inner helper different conditions in foreach loop, how manage that?
i want have different foreach loop, rest of helper should same different version
1 - foreach (var item in model.where(_ => _.version > 0)) 2 - foreach (var item in model.where(_ => _.version = 0)) 3 - foreach (var item in model)
any suggestions?
@helper writegrid() { foreach (var item in model.where(_ => _.version > 0)) { <div> @item.from </div> } }
you can change @helper
bit take func<t,bool>
can decide items show:
@helper writegrid(func<mymodel, bool> p) { foreach (var item in model.where(p)) { <div>@item.from</div> } } @writegrid(x => x.version > 0) <hr/> @writegrid(x => x.version == 0) <hr/> @writegrid(x => true) <hr/>
Comments
Post a Comment