I have a database in my windows phone app. From a Table I need to select some rows. I need to apply more than one Where conditions in my query. How can I write such a query?
My table contains Username, DocumentId, FileType, FileLocation, FileSize etc..
I need to select rows using Username, DocumentId and FileType. How to write the query for that?
Now I am using the following code :
using (DocumentDataContext DocDb = new DocumentDataContext(strConnectionString))
{
IQueryable<Document> DocQuery = from Doc in DocDb.Documents where Doc.UserName == txtName.Text select Doc;
Document Docs= DocQuery.FirstOrDefault();
}
I can select one document using this query. I want to select all rows satisfy the conditions. Can I do this in a single query?
Of course you can. You can extend your
wherecondition using standard or/and keywords:To get more than one row use
ToListinstead ofFirstOrDefault. It returns a list of elements containing the query results: