locked
Entity Framework 6.x - using SQL Server Views RRS feed

  • Question

  • I have this application that i have to fix and maintain. It has a mobile app, a web app dashboard, some web services (2 layers) and some SQL Stored procedures to load some initial data (big picture). My problems is i have a policy number has 3 location address records. The dashboard is pulling back 9 records of the same location. The issue i believe is in the web service layer that is using EF6 and it's using an Inspection table and a PolicyInfo view. Code did this var iList = dbContext.Inspection.Include("PolicyInfo") and .Where() and a couple OrderBy() ands with a .ToList(). This should work fine if we had two tables with proper navigation properties for EF. however, the view "PolicyInfo" is not a table but a SQL Server view. the Coder that did this seemed to not know you can't include a table and a view. The applications are expecting this object with two layers Inspection with a PropertyInfo object. I need to change this to a join on three or more fields. I have 3 records in the Inspection table with different locations and my dashboard is pulling 9 records with the same address. I have multiple extra records coming from the Inspection table and when i comment back in the Include("PolicyInfo") view i still have 9 records. Initially i thought the include to the PolicyView was causing the issue. Does anyone have a clue as to how to solve this type of issue? I know i can do some type of join but then my data will be flat. I need to keep the object in tack to make the two app work as is.
    Wednesday, June 24, 2020 3:32 PM

All replies

  • Hi CS-Shooter,

    This seems to be related to web application. Maybe ASP.NET Entity Framework is a better choice to post this issue.

    Thank you for your understanding.

    Regards,

    Kyle


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, June 25, 2020 5:16 AM