O'Reilly Forums: Error A First Chance Exception Of Type System.data.entitycommandexecutionexception Occurred In System.data.entity.dll - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Error A First Chance Exception Of Type System.data.entitycommandexecutionexception Occurred In System.data.entity.dll

#1 User is offline   dharric 

  • New Member
  • Pip
  • Group: Members
  • Posts: 4
  • Joined: 23-August 10

Posted 23 August 2010 - 09:53 AM

I have seen this error for other user's, even in this forum. But not in my particular context. I have built a silverlight reporting application which is using wcf and entity framework for data retrieval. Everything seems to work fine initially but after having run through several reports I get the error above on calls that initial were working. In other words there seems to be some sort of resource issue in my code somewhere. Unfortunately that line is the only error I'm getting back. But I do suspect that the exception itself is coming from somewhere in the following code:

CODE
public T GetPatchInventoryByQueryString<T,I>(string queryStr)
            where T : IList<I>
            where I : IPatchInventory
        {
            EntityConnection econn = new EntityConnection("name=LDMS861Entities1");
            try
            {
                IList<PatchInventory> patches = _container.Resolve<IList<PatchInventory>>();

                if (econn.State == ConnectionState.Closed)
                    econn.Open();
                using (econn)
                {
                    using (EntityCommand scmd = new EntityCommand(queryStr, econn))
                    {
                        using (EntityDataReader edr = scmd.ExecuteReader(CommandBehavior.SequentialAccess))
                        {
                            while (edr.Read())
                            {
                                patches.Add(GetPatchInventoryByDataRecord<PatchInventory>(edr));
                            }
                        }
                        return (T)patches;
                    }
                }
            }
            finally
            {
                if (econn.State == ConnectionState.Open)
                {
                    econn.Close();
                    econn.Dispose();
                }
            }
        }


Any ideas?
0

#2 User is offline   JulieLerman 

  • Advanced Member
  • PipPipPipPipPipPipPipPip
  • Group: O'Reilly Author
  • Posts: 334
  • Joined: 17-September 08

Posted 05 October 2010 - 05:41 AM

not too many ideas here. Seems that there is some collision here but without the details bedhind that error message, I can't tell.

julie
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users