2

I have a view on some data in my database it returns the data as I would expect, for example

Call Date    To     From   Phone Number
20/1/2010    00:00  23:59  08923233223
20/1/2010    00:00  23:59  08923233245

However when I have added this to my Entity Model and query it I get duplicate(and unexpected) data appearing

Call Date    To     From   Phone Number
20/1/2010    00:00  23:59  08923233223
20/1/2010    00:00  23:59  08923233223

I am simply binding a Entity Data Source to this Entity but I am left scratching my head as to why the data is being returned differently

EDIT: Interestingly this can't be the result of some strange under the hood join as the row counts match as expected. I have also put together a query myself to test with the same odd results

From o In App.Entities.v_PersonalRules Where o.companyid = CompanyID Select o

I am using Visual Studio 2010, .NET 4

Has anyone experienced similar problems?

EDIT: The front end code is fairly simple

  <asp:EntityDataSource ID="EDS_Personal" runat="server" ConnectionString="name=Entities_NEW"
                                    DefaultContainerName="Entities_NEW" EnableDelete="True" EnableInsert="False"
                                    EnableUpdate="True" EntitySetName="v_PersonalRules" EntityTypeFilter="v_PersonalRules" >
                                </asp:EntityDataSource>

which is the data source for the gridview below

<asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False" DataSourceID="EDS_Personal"
                                    EnableModelValidation="True" AllowPaging="True" AllowSorting="True" CssClass="nice_table" PagerStyle-CssClass="cssPager" AutoGenerateDeleteButton="true" AutoGenerateEditButton="true" >
                                    <Columns>
                                          <asp:CommandField ButtonType ="Link" EditText="Edit" ShowEditButton="true" />
                                          <asp:BoundField DataField="billdate" HeaderText="Bill Date" SortExpression="billdate" DataFormatString="{0:dd-MM-yyyy}"  />
                                          <asp:BoundField DataField="starttime" HeaderText="From" SortExpression="starttime" DataFormatString="{0:t}"/>
                                          <asp:BoundField DataField="endtime" HeaderText="To" SortExpression="endtime" DataFormatString="{0:t}" />
                                          <asp:BoundField DataField="description" HeaderText="Type" SortExpression="description" />
                                          <asp:BoundField DataField="HSNumber" HeaderText="Calls From" SortExpression="HSNumber" />
                                          <asp:BoundField DataField="uid" HeaderText="uid" SortExpression="uid" visible="true"/>
                                          <asp:BoundField DataField="dialledNo" HeaderText="Calls To" SortExpression="dialledNo" />
                                          <asp:BoundField DataField="companyid" HeaderText="Company ID" SortExpression="companyid" />

                                    </Columns>
                                </asp:GridView>

2 Answers 2

4

I have now solved the issue....the problem arose due to the issues laid out here. Adding the correct entity key solved the issue

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, I faced a same issue today and resolved with your help.
I also found a work around which is posted in the solution pointed out by Dean
0

First thing you should do is capture (using profiler) the sql that is being sent from EF to the server; then paste that into query analyzer and see what results you get back when you run it manually....that'll tell you if it is a client/front-end issue, versus a server issue. (I suspect front end).

4 Comments

Do you have a guide as to how to do this?
I an assuming you are using sql server? If so, all those things can be done right within Management Studio.
I managed to get the SQL generated by the EF and it returns the data as expected?? this has me totally stumped!
Can you post any of your front-end code? (now that you seem to have eliminated the possibility of the server returning bad data from bad sql)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.