tag:blogger.com,1999:blog-5822946.post115377826143098556..comments2014-09-17T10:15:34.033-05:00Comments on Marc's Musings: I can see clearly now, the pain is gone (or how one little virtual makes the whole view clear)IDisposablehttp://www.blogger.com/profile/02275315449689041289noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-5822946.post-48628924342313867652012-09-12T07:45:52.120-05:002012-09-12T07:45:52.120-05:00Obviously Microsoft made internal changes in .NET ...Obviously Microsoft made internal changes in .NET 4.5 and this means some code of the AcquiringObjectDataSourceView is broken. <br /><br />Solution for those who want to use .NET 4.5 (or lower), here you go!<br /><br /><b>Add class IsNet45.cs with following code:</b><br /><br /> public class IsNet45<br /> {<br /> public static bool IsNet45OrNewer()<br /> {<br /> // Class "ReflectionContext" exists from .NET 4.5 onwards.<br /> return Type.GetType("System.Reflection.ReflectionContext", false) != null;<br /> }<br /> }<br /><br /><b>Second, add variable t_ParsingCulture in the AcquiringObjectDataSourceView class:</b><br /><br /> private static readonly Type t_ParsingCulture =<br /> Type.GetType(<br /> "System.Web.UI.WebControls.ParsingCulture, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");<br /><br /><b>In the static constructor of AcquiringObjectDataSourceView, find 'Type[] buildObjectValue' and replace with:</b><br /><br /> Type[] buildObjectValue = null;<br /><br /> //Version specific code<br /> if(IsNet45.IsNet45OrNewer())<br /> {<br /> buildObjectValue = new Type[] { typeof(object), typeof(Type), typeof(string), t_ParsingCulture }; <br /> <br /> } else<br /> {<br /> buildObjectValue = new Type[] { typeof(object), typeof(Type), typeof(string) }; <br /> }<br /><br /><b>Search the 'BuildObjectValue' subroutine and replace with:</b><br /><br /> private static object BuildObjectValue(object value, Type destinationType, string paramName)<br /> {<br /> //Version specific code<br /> if (IsNet45.IsNet45OrNewer())<br /> return s_BuildObjectValue.Invoke(null, new object[] { value, destinationType, paramName, Activator.CreateInstance(t_ParsingCulture) });<br /><br /> return s_BuildObjectValue.Invoke(null, new object[] { value, destinationType, paramName });<br /><br /> }<br /><br />This should work!Anonymoushttps://www.blogger.com/profile/14213138785266454410noreply@blogger.comtag:blogger.com,1999:blog-5822946.post-85514150957048747702008-07-03T04:08:00.000-05:002008-07-03T04:08:00.000-05:00This is a fantastic article. Using your data sourc...This is a fantastic article. Using your data source it is easy to plug your own custom business objects into ObjectDataSource. As you can now update objects properly, and not have to bind to every single property using hidden controls.<BR/><BR/>For our business objects we did the following:<BR/><BR/> public virtual object AcquireDataObject(Type dataObjectType, IDictionary inputParameters)<BR/> {<BR/> #region Generic Controller<BR/><BR/> Type controllerObjectType = this.GetType(this.TypeName);<BR/><BR/> MethodInfo methodGetPrimaryKeyValue = controllerObjectType.GetMethod("GetPrimaryKeyValue", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);<BR/> MethodInfo methodGetEntity = controllerObjectType.GetMethod("GetEntity", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy, null, new Type[] { typeof(object) }, null);<BR/> PropertyInfo propertyPrimaryKey = controllerObjectType.GetProperty("PrimaryKeyDBColumnName", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);<BR/><BR/> string primaryKeyValue = propertyPrimaryKey.GetValue(controllerObjectType, null) as string;<BR/><BR/> object entityPrimaryKey = inputParameters[primaryKeyValue];<BR/> object loadedEntity = methodGetEntity.Invoke(null, new object[] { entityPrimaryKey });<BR/><BR/> return loadedEntity;<BR/> #endregion<BR/><BR/> //return Activator.CreateInstance(dataObjectType);<BR/> }Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5822946.post-29612996233826359202008-06-05T15:36:00.000-05:002008-06-05T15:36:00.000-05:00Extremely useful post by the way...By setting the ...Extremely useful post by the way...<BR/><BR/>By setting the update method on your ODS to one that does NOT take a business object as an input parameter, you can prevent the ODSV from calling Activator.CreateInstance. Because the ODS's DataObjectTypeName will be null if you use an update method that takes a boatload of object properties and keys as input parameters, this line of code will prevent the Activator.CreateInstance call:<BR/><BR/>if (dataObjectType != null)<BR/><BR/>This is the 8th line of code in the ExecuteUpdate method of the ODSVAndrewhttps://www.blogger.com/profile/01174630370937086286noreply@blogger.comtag:blogger.com,1999:blog-5822946.post-66682564979295134092008-02-04T03:14:00.000-06:002008-02-04T03:14:00.000-06:00It's of a great use for us using BLToolkit for ORM...It's of a great use for us using BLToolkit for ORM! Thank you!<BR/>A single problem - schema isn't transferred correctly to visual controls of ASP.NET when using your wonderful AODS (refresh schema doesn't work).<BR/>Could you help with some directions on where I should look to fix it? It's not a big issue, but still a bit inconvinient...<BR/><BR/>I'd appreciate any help to kyrel[at]list[dot]ru<BR/><BR/>BR,<BR/>Mikhail KirillovAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5822946.post-69421421315865045342007-04-12T03:15:00.000-05:002007-04-12T03:15:00.000-05:00I had the same issues; we went down a different pa...I had the same issues; we went down a different path using a proxy and generics.<BR/><BR/><A HREF="http://adammills.wordpress.com/2007/04/12/the-evil-of-objectdatasource-overcome/" REL="nofollow">Posted Here</A>Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5822946.post-1156259748442611902006-08-22T10:15:00.000-05:002006-08-22T10:15:00.000-05:00Hi Marc,this is indeed a major pain you are trying...Hi Marc,<BR/>this is indeed a major pain you are trying to resolve here... I think it will be of great use for us.<BR/>However, I could not find the source code for AcquringObjectDataSource class in your download section.<BR/>Will it be possible to make it available, as well as a working sample if you got one.<BR/><BR/>Thank you in advance, Eyal.Anonymousnoreply@blogger.com