Exemplo n.º 1
0
        public static List <People> GetPeople(string searchValue, string columnName)
        {
            var db = new SampleDBDataContext(Connection);

            switch (columnName)
            {
            case "LastName":
                var lastNameQuery = db.Peoples.Where(x => x.LastName == $"{searchValue}").ToList();
                return(lastNameQuery);

            case "FirstName":
                var firstNameQuery = db.Peoples.Where(x => x.FirstName == $"{searchValue}").ToList();
                return(firstNameQuery);

            case "EmailAddress":
                var emailAddressQuery = db.Peoples.Where(x => x.EmailAddress == $"{searchValue}").ToList();
                return(emailAddressQuery);

            case "PhoneNumber":
                var phoneNumberQuery = db.Peoples.Where(x => x.PhoneNumber == $"{searchValue}").ToList();
                return(phoneNumberQuery);

            default:
                return(null);
            }
        }
Exemplo n.º 2
0
        public static IEnumerable <string> GetTablesName()
        {
            var db = new SampleDBDataContext(Connection);

            var columnNames = from t in typeof(People).GetProperties()
                              select t.Name;

            return(columnNames);
        }
Exemplo n.º 3
0
        public static void DeleteRecord(People person)
        {
            var db = new SampleDBDataContext(Connection);

            var deleteQuery = from p in db.Peoples
                              where p.id == person.id
                              select p;

            db.Peoples.DeleteAllOnSubmit(deleteQuery);
            db.SubmitChanges();
        }
Exemplo n.º 4
0
        public static List <People> GetAllRecords()
        {
            var           db = new SampleDBDataContext(Connection);
            List <People> allRecordsQuery = new List <People>();

            foreach (var line in db.Peoples)
            {
                allRecordsQuery.Add(line);
            }

            return(allRecordsQuery);
        }