[Mono-dev] [Mono-patches] r115240 - in trunk/mcs/class/System.Web.Extensions: . System.Web.UI.WebControls

Rodrigo Kumpera kumpera at gmail.com
Wed Oct 8 12:40:58 EDT 2008


Hi Atsushi,

I got a few questions about your commit r115240.

Any reason to use "...GetSetMethod ().Invoke (entity, new object []
{p.Value});" instead of just "..SetValue (entity, p.Value, null);"?
They produce the same result.

The ExecuteInsert method does a lot of reflection searches for what looks
like a finite and small set of types. If this method
end been called frequently enough it will be a performance bottleneck as
such calls are synchronized under a single lock.

It is a good a idea to cache the results of GetProperty() and
GetSetMethod().

Thanks,
Rodrigo


Modified:
> trunk/mcs/class/System.Web.Extensions/System.Web.UI.WebControls/LinqDataSourceView.cs
> ===================================================================
> ---
> trunk/mcs/class/System.Web.Extensions/System.Web.UI.WebControls/LinqDataSourceView.cs
>       2008-10-08 16:13:20 UTC (rev 115239)
> +++
> trunk/mcs/class/System.Web.Extensions/System.Web.UI.WebControls/LinqDataSourceView.cs
>       2008-10-08 16:17:05 UTC (rev 115240)
> @@ -221,10 +235,24 @@
>                        throw new NotImplementedException ();
>                }
>
> -               [MonoTODO]
>                protected override int ExecuteInsert (IDictionary values)
>                {
> -                       throw new NotImplementedException ();
> +                       var dc = (DataContext) GetDataContext ();
> +                       foreach (var mt in dc.Mapping.GetTables ()) {
> +                               if (mt.TableName != TableName)
> +                                       continue;
> +
> +                               var t = mt.RowType.Type;
> +                               ITable table = dc.GetTable (t);
> +                               object entity = Activator.CreateInstance
> (t);
> +                               // FIXME: merge InsertParameters
> +                               foreach (DictionaryEntry p in values)
> +                                       t.GetProperty ((string)
> p.Key).GetSetMethod ().Invoke (entity, new object [] {p.Value});
> +
> +                               InsertDataObject (dc, table, entity);
> +                               return 1;
> +                       }
> +                       throw new InvalidOperationException (String.Format
> ("Table '{0}' was not found on the data context '{1}'", TableName,
> ContextType));
>                }
>
>                [MonoTODO]
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20081008/17c773fa/attachment-0001.html 


More information about the Mono-devel-list mailing list