locked
Entity framework - Retrieve related entity - Fetch Order - SQL Server 2008 R2 RRS feed

  • Question

  • Hi,

    I am facing a strange issue. Here is description -

    I have a Winform, database oriented application written in C# VS 4.0 [VS 2012]. I am using entity framework to communicate with SQL Server 2008 R2. In application i have several related entities. When i first time retrieve related entities the entities are fetched in decreasing order [un-desired way] of UID [Unique ID] of related entities. Now if i close the application and relaunch it, and then again try to access the same related entities, this time it comes in ascending order [Desired way] of UID. It is very strange to me. I debugged and found that while processing related entities, first time order of UID is in descending while on next time [after closing and reopening app] related entities are in ascending order of UID. It happens only once. The issue is reproducible if i backup the database and then restore the backedup DB. The issue again occurs only first time. Closing and again opening the app will not show the issue.

    Could any one help me in this regard? Any help would be highly appreciable.

    Let me know if more information is needed.


    ITChamp

    Thursday, August 29, 2013 1:11 PM

All replies

  • Hello ITChamp,

    Welcome toMSDN Support Forum.

    From your description, you want to know why the first time the entities are fetched in decreasing order and in ascending order.

    If I have misunderstood, please let me know.

    I am sorry that I cannot provide an image of the issue.

    So if it possible, could tell me information as following:

    1.            Which Entity Framework Mode you have choose: DataBase-First, Code-First, Model-First?

    2.            How do you bang the data: banding data directly to the controls, binding data in the background?

    3.            What are the table structures of yours?

    4.            Your query statement codes.

    Or you can share your whole program in your skydrive so that we can download it and test it.

    The skydrive link:

    https://skydrive.live.com/

    I look forward to hearing from you.

    Best Regards.

    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.




    • Edited by Fred Bao Friday, August 30, 2013 7:38 AM Better
    Friday, August 30, 2013 7:08 AM
  • Hi Fred Bao,

    I am sorry that i am replying soooo late:(. Actually, the issue was put on hold and now it again came on priority. So thought of to write you. Here are the answers of your questions -

    1.            Which Entity Framework Mode you have choose: DataBase-First, Code-First, Model-First? - Database-First

    2.            How do you bang the data: banding data directly to the controls, binding data in the background?

    Directly to the controls

    3.            What are the table structures of yours?

    Its very simple - two tables are related to each other using foreign key.

    4.            Your query statement codes.

    I am calling to get navigational properties as -

    empObj.Subjects

    Let me know if you have any further question.


    ITChamp

    Wednesday, February 12, 2014 8:55 PM