New Posts New Posts RSS Feed: Incorrect record count on query
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Incorrect record count on query

 Post Reply Post Reply
Author
rclarke View Drop Down
Groupie
Groupie


Joined: 14-Jun-2007
Location: United States
Posts: 69
Post Options Post Options   Quote rclarke Quote  Post ReplyReply Direct Link To This Post Topic: Incorrect record count on query
    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?
Back to Top
midnit View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post 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.


Edited by midnit - 04-Oct-2010 at 9:28am
Back to Top
rclarke View Drop Down
Groupie
Groupie


Joined: 14-Jun-2007
Location: United States
Posts: 69
Post Options Post Options   Quote rclarke Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down