I have two tables: baswareCatalog.FlowCurrent and baswareCatalog.Doc.
They both contain the attribute DocId.
The Doc-table also has the attributes LastExpireDate and Status.
FlowCurrent-table also has the attribute RecipientName.
I want to retrieve a collection of Doc, where the DocId of the item is the same in both tables.
Furthermore, this condition must be true: flowCurrent.RecipientName.Contains(userFullName)
I tried the following, but I don’t know if it is correct.
var docitemIQueryable = from flowCurrent in baswareCatalog.FlowCurrent join
document in baswareCatalog.Docs on
flowCurrent.DocId equals document.DocId
where flowCurrent.RecipientName.Contains(userFullName)
select new
{
Items = baswareCatalog
.Docs
.Where(b => b.DocId == flowCurrent.DocId)
};
The return-value is
'interface System.Linq.IQueryable<out T>'.
T is 'a'
Anonymous Types: 'a is new {IQueryable<Doc> Items }'
How do I retrieve a collection of Doc that I can iterate over?
Two things:
System.Linq.IQueryableis a collection that you can iterate over. You can put it in aforeachloop or do whatever you want with it. Or you can use.ToList()if you want to immediately materialize it.FlowCurrentandDocs, but then you’re taking the results and going right back toDocsagain. You don’t need to do that.Assuming what you care about is just the stuff in
Docs, try this:That will give you a collection of rows with all the fields in
Docs. If you need some of the stuff inFlowCurrentas well then you’ll need to do something more like this: