Print Page | Close Window

Multiple DB calls when accessing a View

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=3984
Printed Date: 05-Sep-2025 at 12:51am


Topic: Multiple DB calls when accessing a View
Posted By: jeanb
Subject: Multiple DB calls when accessing a View
Date Posted: 06-Feb-2013 at 8:05pm
I have a strange problem.  I have a normal SQL view which I have added to my entity model (it has 2993 rows).  I call entitymanager.(myviews).ExecuteAsync().  I trace this in SQL profiler.  I see the normal batch call.  I then see 350 SP calls with exactly the same batch call SQL query.

I thought maybe the problem was the view didn't have a primary key, so I added one as a string combination of primary keys, and I updated the model entity so that this was the only entity key, but it had no effect.

I am stumped.  Why is IdeaBlade calling the exact same SQL code 350 times after the batch call?  If I call the view with a specific record, it does the same thing.

I've added the 3 of the SQL trace rows below, there are 350 more of these:

OperationsEntities.vwSupplierServiceRouteYesList.ExecuteAsync();

SQL:BatchStarting
SELECT
[Extent1].[SupplierId] AS [SupplierId],
[Extent1].[SupplierAccountNumber] AS [SupplierAccountNumber],
[Extent1].[SupplierName] AS [SupplierName],
[Extent1].[SupplierServiceId] AS [SupplierServiceId],
[Extent1].[SupplierService] AS [SupplierService],
[Extent1].[RouteId] AS [RouteId],
[Extent1].[RouteCode] AS [RouteCode],
[Extent1].[Route] AS [Route],
[Extent1].[IsPreferredSupplier] AS [IsPreferredSupplier],
[Extent1].[AutoGenerateSupplierManifestNumber] AS [AutoGenerateSupplierManifestNumber],
[Extent1].[PrimaryKey] AS [PrimaryKey]
FROM (SELECT
      [vwSupplierServiceRouteYes].[SupplierId] AS [SupplierId],
      [vwSupplierServiceRouteYes].[SupplierAccountNumber] AS [SupplierAccountNumber],
      [vwSupplierServiceRouteYes].[SupplierName] AS [SupplierName],
      [vwSupplierServiceRouteYes].[SupplierServiceId] AS [SupplierServiceId],
      [vwSupplierServiceRouteYes].[SupplierService] AS [SupplierService],
      [vwSupplierServiceRouteYes].[RouteId] AS [RouteId],
      [vwSupplierServiceRouteYes].[RouteCode] AS [RouteCode],
      [vwSupplierServiceRouteYes].[Route] AS [Route],
      [vwSupplierServiceRouteYes].[IsPreferredSupplier] AS [IsPreferredSupplier],
      [vwSupplierServiceRouteYes].[AutoGenerateSupplierManifestNumber] AS [AutoGenerateSupplierManifestNumber],
      [vwSupplierServiceRouteYes].[PrimaryKey] AS [PrimaryKey]
      FROM [dbo].[vwSupplierServiceRouteYes] AS [vwSupplierServiceRouteYes]) AS [Extent1]

SP:Starting
SELECT
[Extent1].[SupplierId] AS [SupplierId],
[Extent1].[SupplierAccountNumber] AS [SupplierAccountNumber],
[Extent1].[SupplierName] AS [SupplierName],
[Extent1].[SupplierServiceId] AS [SupplierServiceId],
[Extent1].[SupplierService] AS [SupplierService],
[Extent1].[RouteId] AS [RouteId],
[Extent1].[RouteCode] AS [RouteCode],
[Extent1].[Route] AS [Route],
[Extent1].[IsPreferredSupplier] AS [IsPreferredSupplier],
[Extent1].[AutoGenerateSupplierManifestNumber] AS [AutoGenerateSupplierManifestNumber],
[Extent1].[PrimaryKey] AS [PrimaryKey]
FROM (SELECT
      [vwSupplierServiceRouteYes].[SupplierId] AS [SupplierId],
      [vwSupplierServiceRouteYes].[SupplierAccountNumber] AS [SupplierAccountNumber],
      [vwSupplierServiceRouteYes].[SupplierName] AS [SupplierName],
      [vwSupplierServiceRouteYes].[SupplierServiceId] AS [SupplierServiceId],
      [vwSupplierServiceRouteYes].[SupplierService] AS [SupplierService],
      [vwSupplierServiceRouteYes].[RouteId] AS [RouteId],
      [vwSupplierServiceRouteYes].[RouteCode] AS [RouteCode],
      [vwSupplierServiceRouteYes].[Route] AS [Route],
      [vwSupplierServiceRouteYes].[IsPreferredSupplier] AS [IsPreferredSupplier],
      [vwSupplierServiceRouteYes].[AutoGenerateSupplierManifestNumber] AS [AutoGenerateSupplierManifestNumber],
      [vwSupplierServiceRouteYes].[PrimaryKey] AS [PrimaryKey]
      FROM [dbo].[vwSupplierServiceRouteYes] AS [vwSupplierServiceRouteYes]) AS [Extent1]

SP:Starting
SELECT
[Extent1].[SupplierId] AS [SupplierId],
[Extent1].[SupplierAccountNumber] AS [SupplierAccountNumber],
[Extent1].[SupplierName] AS [SupplierName],
[Extent1].[SupplierServiceId] AS [SupplierServiceId],
[Extent1].[SupplierService] AS [SupplierService],
[Extent1].[RouteId] AS [RouteId],
[Extent1].[RouteCode] AS [RouteCode],
[Extent1].[Route] AS [Route],
[Extent1].[IsPreferredSupplier] AS [IsPreferredSupplier],
[Extent1].[AutoGenerateSupplierManifestNumber] AS [AutoGenerateSupplierManifestNumber],
[Extent1].[PrimaryKey] AS [PrimaryKey]
FROM (SELECT
      [vwSupplierServiceRouteYes].[SupplierId] AS [SupplierId],
      [vwSupplierServiceRouteYes].[SupplierAccountNumber] AS [SupplierAccountNumber],
      [vwSupplierServiceRouteYes].[SupplierName] AS [SupplierName],
      [vwSupplierServiceRouteYes].[SupplierServiceId] AS [SupplierServiceId],
      [vwSupplierServiceRouteYes].[SupplierService] AS [SupplierService],
      [vwSupplierServiceRouteYes].[RouteId] AS [RouteId],
      [vwSupplierServiceRouteYes].[RouteCode] AS [RouteCode],
      [vwSupplierServiceRouteYes].[Route] AS [Route],
      [vwSupplierServiceRouteYes].[IsPreferredSupplier] AS [IsPreferredSupplier],
      [vwSupplierServiceRouteYes].[AutoGenerateSupplierManifestNumber] AS [AutoGenerateSupplierManifestNumber],
      [vwSupplierServiceRouteYes].[PrimaryKey] AS [PrimaryKey]
      FROM [dbo].[vwSupplierServiceRouteYes] AS [vwSupplierServiceRouteYes]) AS [Extent1]



Replies:
Posted By: jeanb
Date Posted: 06-Feb-2013 at 10:12pm
It's not IdeaBlade or the entity query, it's happening when called from SQL too.  Weird, but not for this forum, sorry.



Print Page | Close Window