1) I wish to clarify some doubts on collections.
SampleDBDataContext PersonDB = new SampleDBDataContext("");
Table<Person> p=PersonDB.GetTable<Person>();
IEnumerable<Person> per = PersonDB.GetTable<Person>();
IQueryable<Person> qry = PersonDB.Persons.Select(c => c);
what are the differences between using Table<Person>,IEnumerable<Person>,IQueryable<Person>.Any specific need to choose the particular one?
2) For Adding records Add() method not appears in my IDE,(i.e) PersonDB.Persons.Add().
What is the problem here?
1.
IEnumerable<>is an interface thatapplies to any collection whose
members can be enumerated or iterated
over.
IQueryable<>is a LINQ interfacethat applies to any collection whose
members can be lazily queried.
(queried without materializing the
result set until its members are
accessed)
Table<>is a class that I’venot used before but “represents a
table for a particular type in the
underlying database.”
Which one you choose depends on what your needs are, but
IEnumerable<>is the most general, so I would use that in my type declarations if it’s sufficient.2.
To insert a person use
InsertOnSubmit():