Print Page | Close Window

Incorrect record count on query

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2212
Printed Date: 02-Jun-2025 at 9:57am


Topic: Incorrect record count on query
Posted By: rclarke
Subject: Incorrect record count on query
Date Posted: 04-Oct-2010 at 8:24am
I have a wierd problem with one table in my database. The table was created within SQL Server Management Studio by importing data from an Access database. A query from within Management Studio show 48645 records in the table. After updating my model from the database the new table is added and I save and build. When I access this table through DevForce I only get 4 records retruned. Using SQL Server Express 2008 R2 and Devforce 6.0.4.0 The code I use is as follows:
 
'Dim ticketsQuery = _mgr.EntityMgr.Tickets
'Dim ticketsCollection As New ObservableCollection(Of Ticket)
'ticketsQuery.ForEach(Sub(t) ticketsCollection.Add(t))
' Dim accessTicketsQuery = _mgr.EntityMgr.AccessTickets.Where((Function(t) t.TicketDate >= BeginDate And t.TicketDate <= EndDate))
Dim accessTicketsQuery = _mgr.EntityMgr.AccessTickets
 _ticketsFromAccess.Clear()
accessTicketsQuery.ForEach(Sub(t) _ticketsFromAccess.Add(t))
AccessTicketCount = _ticketsFromAccess.Count
 
Note that the commented code was a test I did to see if this problem exists for another table and when executed that code produced
the proper number of records.
I've looked at logs and SQL Profiler and everything seems OK so how do I debug this issue?



Replies:
Posted By: midnit
Date Posted: 04-Oct-2010 at 9:26am
Have you tried querying the Table directly through EF? Or use the model editor to query. Does the table have any joins [associations] in the model? Perhaps it joined incorrectly. I would test the results of just using EF, if those are correct then move to DevForce. Querying the database yourself means you are creating the query and thereby doesn't necessarily use the query that EF will.
 
I would also turn detailed logging on in devforce that way you can see the query string its [EF] using.


Posted By: rclarke
Date Posted: 04-Oct-2010 at 10:48am
I found the problem but I don't know if this is a bug or not. I noticed that when the table was imported, there is no primary key assigned even though Access had one defined. Once I updated the imported table to have a primary key the query works. I know that every table should have a primary key but is it an absolute requirement? Is this a possible EF or DevForce issue



Print Page | Close Window