Hi all -
Apologies in advance if this comes across as a 101 type question. I thought I was in good shape using OA's implementation of LINQ but I have an oddity that I'm not sure what to do about. It may just be that I am coding incorrectly, so feel free to tell me so.
Here's the issue: I am attempting to retrieve all address entries for a specific person in our database, and then iterate through them. I originally thought that this would work:
var obEPMAddressList = from e
in
ctxUIS.PS_UA_DPT_CARS_SADs
where e.PERSON_ID == obPerson.EmplID
select e;
// Update what we have.
foreach
(var obEPMAddress
in
obEPMAddressList)
{
[
do
something]
}
But... the foreach iteration only picks up the very first entry and then drops out of the loop.
However, if I do this instead:
var obEPMAddressList = from PS_UA_DPT_CARS_SAD
in
ctxUIS.PS_UA_DPT_CARS_SADs
where PS_UA_DPT_CARS_SAD.PERSON_ID == obPerson.EmplID
select
new
{
PS_UA_DPT_CARS_SAD.ADDR_FIELD1,
[... through n fields of interest ...]
};
// Update what we have.
foreach
(var obEPMAddress
in
obEPMAddressList)
{
[
do
something]
}
...this works. The first code snipped is based on the examples found at http://www.telerik.com/help/openaccess-orm/openaccess-feature-ref-linq-support-querying-query-types.html while the second is based on http://www.telerik.com/help/openaccess-orm/openaccess-feature-ref-linq-support-querying-query-result.html.
The kicker is that if I test the first statement outside of OpenAccess and in a tool such as LINQPad, it retrieves all records properly. I'm wondering if I've just missed a finer point on the OA syntax here. Thanks for any help!
-- Chris