Bug #59619 GetDataTypeName Return Wrong Type
Submitted: 19 Jan 2011 20:07 Modified: 23 Jan 2011 18:36
Reporter: Mohamed Rashed Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:6.3.6 OS:Windows
Assigned to: Bogdan Degtyariov CPU Architecture:Any
Tags: GetDataTypeName Wrong Type

[19 Jan 2011 20:07] Mohamed Rashed
Description:
Method GetDataTypeName Return Wrong Type int while it must be DateTime :

create entity data model that work with table contain DateTime column where i get error can't cast int46 as DateTime so we can't use entity data model if tables contain DateTime Value  

How to repeat:
The result of a query cannot be enumerated more than once. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: The result of a query cannot be enumerated more than once.

Source Error: 

Line 24:             WebApplication1.Model.chatEntities chat = new Model.chatEntities();
Line 25:             var usersList = chat.GetUsers();
Line 26:             user = usersList.First();
Line 27: 
Line 28:             GridView1.DataSource = user;
 

Source File: E:\my project\WebApplication1\WebApplication1\WebForm1.aspx.cs    Line: 26 

Stack Trace: 

[InvalidOperationException: The result of a query cannot be enumerated more than once.]
   System.Data.Objects.ObjectResult`1.GetEnumerator() +8402498
   System.Linq.Enumerable.First(IEnumerable`1 source) +176
   WebApplication1.WebForm1.Button1_Click(Object sender, EventArgs e) in E:\my project\WebApplication1\WebApplication1\WebForm1.aspx.cs:26
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563

 

Suggested fix:
you must fix method GetDataTypeName to return correct data
[20 Jan 2011 9:08] Bogdan Degtyariov
Hi Mohamed,

I have created a table with DateTime column in MySQL Server.
Then I made a new web-project in Visual Studio 2010 and added ADO.NET Entity Data Model.

As you can see on the screenshot (bug_59619_screenshot.jpg) uploaded below, the table is imported and the properties windows shows the correct type "DateTime".

Please advise if I need to perform some additional steps.
Thanks.
[20 Jan 2011 9:09] Bogdan Degtyariov
Entity data model in VS 2010

Attachment: bug_59619_screenshot.jpg (image/jpeg, text), 139.80 KiB.

[23 Jan 2011 18:36] Mohamed Rashed
I have rebuild the selution then this error not appear again may be something is wrong with my old code so i am very sorry for this disturbance it work fine know and you can check out this issue
[24 Jan 2011 2:12] Bogdan Degtyariov
Mohamed,

Thanks for you feedback and for reporting the problem.
It is always better to check possible issues rather than overlook a real problem.