Dynamic Casting with .NET(www.codecapers.com)

submitted by mceranskimceranski(345) 1 year, 10 months ago

I recently was working on a project where I needed to store settings or various data types into a database table. Since most of the settings were singular I ended up with a table that had two columns which were titled name and value. The name and value field of the Setting table are both defined as varchars ( or strings). By defining the value field as a string, I can serialize any object to the table by using the ToString() method. Over time my application could grow to have dozens of settings of varying data types. So I needed a mechanism to load the settings from the table and assign them to an object. While loading each setting, I need to dynamically determine the data type of each field and dynamically cast it to the correct type.

add a comment |category: |Views: 10

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

No comments so far

information Login or create an account to comment on this story