예제 #1
0
        public static void RemoveBinding(ModelStateDictionary modelState, params string[] properties)
        {
            var props     = properties.ToList();
            var indexList = new List <int>();

            for (int i = 0; i < props.Count; i++)
            {
                modelState.Keys.ToList().ForEach(k =>
                {
                    if (k.Contains(props[i]))
                    {
                        indexList.Add(modelState.Keys.ToList().IndexOf(k));
                    }
                });
            }

            if (indexList.Any())
            {
                indexList.ForEach(i =>
                {
                    modelState.Remove(modelState.ElementAt(i));
                });
            }
        }