public bool CheckUser() { DataTable dt = new DataTable(); dt = dataAuthentication.GetUserInfo(this.UserName, this.Password); if (dt.Rows.Count > 0) { var e = dt.AsEnumerable().Select(g => new User { UserID = g.IsNull("UserID") ? 0 : g.Field <int>("UserID"), UserName = g.IsNull("UserName") ? "" : g.Field <string>("UserName"), DataSourcekey = g.IsNull("DataSourcekey") ? "" : g.Field <string>("DataSourcekey"), Type = g.IsNull("UserType") ? UserType._User : g.Field <UserType>("UserType"), }).First(); UserID = e.UserID; UserName = e.UserName; DataSourcekey = e.DataSourcekey; Type = e.Type; return(true); } else { return(false); throw new Exception("Authentication Failed"); } }