PC Review


Reply
Thread Tools Rate Thread

Accessing object properties

 
 
Kevin
Guest
Posts: n/a
 
      10th Oct 2008
I'm looking for a way to create a generic function that will take a LinqToSql
object, a Field name and a value that will assign the value to the field. is
this possible?
 
Reply With Quote
 
 
 
 
Jeroen Mostert
Guest
Posts: n/a
 
      10th Oct 2008
Kevin wrote:
> I'm looking for a way to create a generic function that will take a LinqToSql
> object, a Field name and a value that will assign the value to the field. is
> this possible?


Sure, but it has nothing to do with LINQ to SQL. If you have any object, you
can manipulate it through reflection -- Type.GetProperty() and friends
should do the trick.

Be aware that reflection carries a significant performance penalty. The
point of LINQ to SQL is to bridge the gap between objects and tables by
allowing strongly-typed access to the underlying database. If you're going
to use generic "set X to Y" logic, you're throwing away the benefits and you
might as well stick to using DataTable, which was made for just such an
approach.

--
J.
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing a Parent Object's Properties RSH Microsoft VB .NET 8 9th Mar 2007 07:02 PM
Arraylist - accessing object properties? Alex Microsoft C# .NET 3 20th Oct 2006 08:58 PM
Accessing Properties on an object with special attributes Thorsten Viel Microsoft C# .NET 4 18th Jul 2006 11:31 PM
RE: Accessing all properties of an object at Runtime Yan-Hong Huang[MSFT] Microsoft ASP .NET 0 7th Jul 2003 08:13 AM
Re: Accessing all properties of an object at Runtime Ilyas Microsoft ASP .NET 1 4th Jul 2003 06:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:04 PM.