做添加或修改时判断用户名name是否存在
当name可以修改的时候
public bool IsExistTankNameByInputName(long tankId, string inputName){ #region when name is not edit if (id == 0)//add { count = GetTankList().Where(e => e.Name == name).ToList().Count; if (count == 0) isExist = false; } else//edit { count = GetTankList().Where(e => e.TankID == id && e.Name == name).ToList().Count; if (count == 1) isExist = false; } #endregion return isExist;}
注解:
GetTankModelList()与GetTankList()都是一个list集合
GetTankModelByTankId根据id取得list集合