yasser777 / nettiers

Automatically exported from code.google.com/p/nettiers
0 stars 0 forks source link

The entity object cannot be null. #396

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. use EntityFridView and EntityDataSource
2. use SelectMethod - custom stored procedure
3. try to update row in GridView (on web site)

What is the expected output? What do you see instead?
Row must updating.
Instead you get "The entity object cannot be null.". 
If use SelectMethod GetPaged - all ok, if other custom proc - fail!

What version of .netTiers and CodeSmith are you using?
nettiers 2.3.1, codesmith 4

Please use labels and text to provide additional information.

Original issue reported on code.google.com by kinguru2...@gmail.com on 23 Aug 2011 at 8:40

GoogleCodeExporter commented 9 years ago
Hello,

Could you please paste the stack trace that you are seeing when this error 
occurs.

Thanks
-Blake Niemyjski

Original comment by bniemyjski on 23 Aug 2011 at 8:57

GoogleCodeExporter commented 9 years ago
Exception raises in entity validation method:

Server Error in '/' Application.

The entity object cannot be null.

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.NullReferenceException: The entity object cannot be 
null.

Source Error:

An unhandled exception was generated during the execution of the current web 
request. Information regarding the origin and location of the exception can be 
identified using the exception stack trace below.

Stack Trace:

[NullReferenceException: The entity object cannot be null.]
SOMEAPP.Web.Data.BaseDataSourceView`2.ValidateEntity(Entity entity, IDictionary 
keys) in 
d:\projects\SOMEAPP.ua\solution.nettiers\SOMEAPP\SOMEAPP.Web\Data\BaseDataSource
.cs:1943
SOMEAPP.Web.Data.BaseDataSourceView`2.ExecuteUpdate(IDictionary keys, 
IDictionary values, IDictionary oldValues) in 
d:\projects\SOMEAPP.ua\solution.nettiers\SOMEAPP\SOMEAPP.Web\Data\BaseDataSource
.cs:1561
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, 
IDictionary oldValues, DataSourceViewOperationCallback callback) +95
System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 
rowIndex, Boolean causesValidation) +1226
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean 
causesValidation, String validationGroup) +716
System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +95
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) 
+121
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +125
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) 
+169
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String eventArgument) +9
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, 
String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +176
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, 
Boolean includeStagesAfterAsyncPoint) +5563

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET 
Version:4.0.30319.1

Original comment by kinguru2...@gmail.com on 25 Aug 2011 at 12:04

GoogleCodeExporter commented 9 years ago
Is there any ideas about this?

Original comment by kinguru2...@gmail.com on 31 Aug 2011 at 9:37

GoogleCodeExporter commented 9 years ago
Hello,

I couldn't reproduce this using the PetShop Database. I ran the stored 
procedures template (ships with codesmith) and then changed the datasource on 
the admin category page to:

        <data:CategoryDataSource ID="CategoryDataSource" runat="server"
            SelectMethod="Category_SelectCategoriesAll"

Then I built the project and tried updating the record on the categories page. 

Can you create and attach a sample with a db script that can reproduce this. 
I'd recommend setting a breakpoint on line 1943 of BaseDataSource.cs 
(ValidateEntity()) and see why the passed in entity is null.

Original comment by bniemyjski on 1 Sep 2011 at 7:45

GoogleCodeExporter commented 9 years ago
I will create test-project with DB attached later, it's not easy.
Can you set SelectMethod to method with parameters, like GetBySomething, where 
GetBySomething is your custom stored procedure?

In debug i saw that Entity parameter in ValidateEntity method is null.
Because Entity was looked by PARAMETER key, not DataFieldKeyName field of  
GridView and it was strange.

All bugs was fallen on me after I upgrade my netTiers to 2.3.1 version from 
previous version. And all working pages I rewrote  after updating :(
That's why I insist to test your templates one more time, please!

Original comment by kinguru2...@gmail.com on 2 Sep 2011 at 8:13

GoogleCodeExporter commented 9 years ago
Hello,

I'll try to set this to a SP with a parameter but I'll have to do it when I get 
some free time. Please post a sample if you get one before I update this issue. 
We try our best to test and could always use another hand when testing and 
developing features.

Original comment by bniemyjski on 6 Sep 2011 at 2:16