How to get EntityCollection with out having Relations
Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=910
Printed Date: 11-Jun-2026 at 1:15am
Topic: How to get EntityCollection with out having Relations
Posted By: viralvasaiwala
Subject: How to get EntityCollection with out having Relations
Date Posted: 12-Aug-2008 at 12:09am
|
Hi,
We are facing problems while getting record for some of the entities and for that we get a message that
"It Cannot evaluate expression because a native frame is on top of the call stack."
Code Snippet
================================================================
if (objFieldName.Length > 0)
passthruEsqlQuery = new PassthruEsqlQuery(typeObject, new ParameterizedEsql("SELECT VALUE resultsql from " + EnglishGrammarRules.Pluralize(typeObject.Name) + " AS resultsql WHERE " + objFieldName));
else
passthruEsqlQuery = new PassthruEsqlQuery(typeObject, new ParameterizedEsql("SELECT VALUE resultsql from " + EnglishGrammarRules.Pluralize(typeObject.Name) + " AS resultsql WHERE resultsql." + objectName + "." + objectName + "Id LIKE '%" + Id + "%'"));
================================================================
After the above query creation we set the timeout for this PassthruEsqlQuery...
passthruEsqlQuery.CommandTimeout(); // (value for timeout = 2400)
than we execute the query using DataSet in the below two manner (with or without QueryStrategy.DataSourceOnly)
1. IEnumerable iEnumerableResults = DataSet.ExecuteQuery(passthruEsqlQuery);
2. IEnumerable iEnumerableResults = DataSet.ExecuteQuery(passthruEsqlQuery,
QueryStrategy.DataSourceOnly);
but in both scenario we gets the error either of
"Connection Timeout"
OR
"Cannot evaluate expression because a native frame is on top of the call stack".
because of the above errors, I would like to know is there any alternate way to get the data for particular entity without getting its Relations. If possible than please let us know as soon as possible.
Thanks
Viral Vasaiwala
|
Replies:
Posted By: kimj
Date Posted: 12-Aug-2008 at 10:01am
|
Without knowing both your Entity definition and the underlying table schema, and the actual resolved eSQL query, I really can't help diagnose why you're getting these errors. If you'd like help with this you can send a small reproducible case to support.
As for querying an entity without pulling in relations, that's easy to do. Related entities are not fetched except when a) one or more Include statements are part of the query, or b) the query references related entities and must be 'inverted" in order to load cache with all required data. A simple query such as:
var query = entityManager.Customers.Where(c=> c.Id ==1)
will retrieve only the single requested customer and not any related entities.
If you're seeing an EntityQuery which you think is erroneously retrieving related entities too, please post it here.
|
Posted By: viralvasaiwala
Date Posted: 13-Aug-2008 at 5:19am
|
Hello Kim,
Thank you for your prompt reply.
Scenario is that we are going to fetch data from “Correlation” Entity, which has the schema as given. When we are going to fetch data from correlation, it will get data from Partner Entity also as it has a relation with partner.
=========Entity Schema of Correlation =================
CREATE TABLE [dbo].[Correlation]([CorrelationId] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,[DataXml] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[Messages] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[NewestMessageDate] [datetime] NULL,[LastChanged] [datetime] NULL,[DoCorrelation] [bit] NULL,[InternalObject] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[InternalObject_Type] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[Partner] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[CreatedAt] [datetime] NULL,CONSTRAINT [PK__Correlation__10CB707D] PRIMARY KEY CLUSTERED ([CorrelationId] ASC) WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]
====================================================================================
Schema of partner is given below. If partner has any relation with any another entity, then it will get data of that entity. That will give us the time out errors in most of the cases.
======== Entity Schema of Partner======================
CREATE TABLE [dbo].[Partner](
[PartnerId] [nvarchar] (200) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,[ObjectType] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[Name] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[Contact_Address_Street1] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[Contact_Address_Street2] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[Contact_Address_City] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[Contact_Address_State] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[Contact_Address_PostalCode] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[Contact_Address_Country] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[Contact_BillingAddress_Street1] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[Contact_BillingAddress_Street2] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[Contact_BillingAddress_City] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[Contact_BillingAddress_State] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[Contact_BillingAddress_PostalCode] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[Contact_BillingAddress_Country] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[Contact_Phone] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[Contact_PhoneWork] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[Contact_PhoneMobile] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[Contact_PhoneFax] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[Contact_Email] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[Contact_NewEmail] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[Contact_ContactNotes] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[EncryptionKey] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[PublicKey] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[TaxIdNumber] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[PaymentInfo_Method] [nvarchar](16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[PaymentInfo_AccountNumber] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[PaymentInfo_Institution] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[OfacStatus] [nvarchar](6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[ShortName] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[Contact_NewEmailDate] [datetime] NULL,[CorrelationStartDate] [datetime] NULL,[Contact_Address_DateChanged] [datetime] NULL,[Contact_BillingAddress_DateChanged] [datetime] NULL,[InvoiceStartDate] [datetime] NULL,PRIMARY KEY CLUSTERED ([PartnerId] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]=====================================================================================
Looking forward for your reply.
Thanks,
Viral Vasaiwala
|
Posted By: kimj
Date Posted: 13-Aug-2008 at 9:22am
|
Viral,
I'm still not sure I understand why you say that fetching data from Correlation causes an automatic fetch from Partner due to their relationship. Fetching related data is a function of the query, so it may be something you can turn off it you think DevForce is doing it unnecessarily. Can you post your LINQ / EntityQuery too?
|
|