开发者

Reporting Services with Entity Framework

I am using SQL Reporting services to hit a WCF web service.

My query is:

    <Query>
<Method Name="GetADTHistory" Namespace="http://tempuri.org/">
<Parameters>
       <Parameter Name="personId"><DefaultValue>7885323F-DE8D-47E5-907D-2991C838FF3E</DefaultValue></Parameter>
   </Parameters>
</Method>
<SoapAction>
http://tempuri.org/IResidentServiceFrontEnd/GetADTHistory
</SoapAction>
</Query>

My implementation is

public List<ResidentDataTypes.Person> GetADTHistory(Guid personId)
        {
            using (ResidentDataTypes.MyEntities entity = new ResidentDataTypes.MyEntities ())
            {
                var person = (from a in entity.People.Include("ResidentAdts")
                              where a.PersonId == personId
                              select a);

                if (person.Count() > 0)
                {
                    return person.ToList();
                }
开发者_StackOverflow                else
                {
                    return new List<Person>();
                }

            }
        }

This works fine if there are 2 or more ADT records. Reporting services correctly sees all the fields in the database. However if there is only 1 ADT record reporting services sees the 'Person' columns but none of the ADT records. Any ideas?


It looks like that you have an eager/lazy load issue. I suggest you to execute and test the query with linqpad to check if it really includes the ResidentAdts in the case of single record.

I also recommend you to check this thread: Linq to Entities Include Method Not Loading

Adding the "Linq" tag to your question would also helpful.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜