Navigation


Milos Solution Platform (External Blog)

The Milos Solution Platform is .NET's premier platform for building business applications. This blog is meant for developers who use or evaluate Milos. This blog is used to share tidbits of information provided by the Milos developers at EPS. Many of the posts put the spotlight on new features. We generally recommend that all Milos users (developers) at least scan this blog to keep up with the Milos news.

Content Area Footer

Saturday, December 20, 2008
Object casting convenience methods

This upcoming version of Milos has a nice little enhancement in the utilities namespace. The DataHelper class now has extension methods that make it very convenient to cast from object types (such as fields in DataSets) to their real types.

These helper methods are implemented as extension methods. To use them, you have to add this line of code at the top of your program:

using EPS.Utilities;

Now, the extension methods are automatically available on all objects. For instance, you can do the following:

DataSet myDs = this.GetSomeDataSet(); // Assume that we somehow get a DataSet
DataRow row = myDs.Tables[0].Rows[0];
Guid myGuid = row["id"].ToGuidSafe();
string myString = row["name"].ToStringSafe().Trim();
int myInt = row["number"].ToIntegerSafe();

The main advantage here is that these methods always return valid values, even if the cast object is not valid. For instance, these methods are aware of System.DBNull and they also trap errors.

There are a number of different such methods, including the ability to cast to booleans, DateTime, decimal, and so forth (all common value types, basically).



Posted @ 2:03 PM by Egger, Markus (markus@code-magazine.com) -
Comments (18)




Comments:

RE: Object casting convenience methods
Tuesday, June 21, 2011 10:04 PM by new era - vsg@gcv.com

There are a number of different such methods, including the ability to cast to booleans, DateTime, decimal, and so forth


RE: Object casting convenience methods
Tuesday, June 21, 2011 10:10 PM by new era - vsg@gcv.com

These helper methods are implemented as extension methods. To use them, you have to add this line of code at the top of your program:


Herve Leger Dress
Monday, August 29, 2011 5:41 AM by Herve Leger Dress - flyhigh@163.com


yes your article really make me feel comfortable!


RE: Object casting convenience methods
Wednesday, September 21, 2011 8:39 PM by johnsikefeier - guyongbing_33@163.com

Also, don't eat all the beautiful flowers, cheap Oakley sunglasses or kill off the lilies by eating all the bulbs. Use common sense. If you aren't sure if you're doing harm, stick to eating wild berries.


RE: Object casting convenience methods
Tuesday, November 08, 2011 6:42 PM by SWF Converter for Mac - plant2013@gmail.com

Preparation: Free download and install Mac SWF Video Converter, launch it.


Trumpet/ Mermaid Wedding Dress
Friday, November 18, 2011 2:02 AM by Trumpet/ Mermaid Wedding Dress - zhuiyi3693@yahoo.com

As much work as it was doing most of it DIY, it was totally worth it in the end. Plus, having gf amazing vendors makes it SO much better! We worked hard up until the day of, then they took over for us, so we didn’t have to do a thing except enjoy each other and our friends and family.


RE: Object casting convenience methods
Tuesday, November 29, 2011 2:50 AM by JR. Tresor Paris - galas262031416@yahoo.cn

Hi!I came over to visit your site for the first time a


RE: Object casting convenience methods
Monday, December 05, 2011 2:50 AM by Mont blanc Pen - rrolyly02@gmail.com


Should you be a handwriting fan, you absolutely must buy a fountain pen. The fountain pen is a distinctive writing device that contains ink without the use of a cartridge, as a ballpoint pen does.


RE: Object casting convenience methods
Sunday, September 10, 2017 10:23 AM by Interested in Sex - sirking79@gmail.com

Please share more like that.


192.168.0.1 ip login
Tuesday, October 17, 2017 1:32 AM by 192.168.0.1 ip login - kranthisurya@mail.com

192.168.0.1 ip login An IP address 192.168.0.l and 192.168.l.0 and 192.168.0 is a fascinating result of contemporary processor


RE: Object casting convenience methods
Sunday, December 03, 2017 7:57 PM by 192.168.0.1 login - bryklinop@yahoo.com

This article is such a nice and interesting one, I'm very satisfied with the provided contents. I hope more excellent articles would be posted in your website. Thank you so much for this and keep sharing.


RE: Object casting convenience methods
Saturday, December 09, 2017 1:31 AM by run 2 online - happyroomonline@gmail.com

Chances are that PART of your job is that type of work. Why not look half way around the world and find someone else to off-load that part to? Give yourself a little more vacation...


RE: Object casting convenience methods
Tuesday, January 30, 2018 3:41 AM by buy a dissertation - voilettaylor@yahoo.com

buy a dissertation from a UK's most trusted & affordable custom written dissertation provider.


Windshield Repair
Monday, May 28, 2018 8:28 AM by Windshield Repair - mtom78632@gmail.com

Im happy I found this website, I couldnt get any information on this subject prior to. I also manage a website and if you want to ever serious in doing some visitor writing for me if possible feel free to let me know, im always look for people to check out my blog page. Please stop by and leave a comment sometime!


RE: Object casting convenience methods
Wednesday, August 01, 2018 3:26 AM by Help With Coursework - RileyWilliam83@gmail.com

It is nice of you as you shared here upcoming version of Milos which has a nice little improvement in the utilities namespace.


http://www.poker18dewa.com
Saturday, August 18, 2018 2:50 AM by http://www.poker18dewa.com - mtom78632@gmail.com

I don’t commonly comment but I gotta state thankyou for the post on this amazing one : D.


RE: Object casting convenience methods
Tuesday, August 21, 2018 5:01 AM by www.myhoneybakedfeedback.com

The Honeybaked Ham Company is a ham producing franchise which is regarded today as the best-tasting ham in the world. It was founded in 1957 that was 61 years ago.


RE: Object casting convenience methods
Tuesday, August 21, 2018 5:01 AM by www.myhoneybakedfeedback.com

The Honeybaked Ham Company is a ham producing franchise which is regarded today as the best-tasting ham in the world. It was founded in 1957 that was 61 years ago.




Post a Comment:

Comment Title (required)

Your Name (optional)

Your Email (optional)

Your Web Site (optional)

Your Comment (required)

 

 

 

 

 

 

 

Syndication RSS 2.0 RSS 2.0

All My Blogs:
My personal blogs:
Dev and Publishing Dev and Publishing
Travel and Internat. Living Travel and Internat. Living
Other blogs I contribute to:
Milos Blog (US) Milos Blog (US)
VFPConv. Dev Blog (US) VFPConv. Dev Blog (US)
VFPConv. Dev Blog (DE) VFPConv. Dev Blog (DE)

 

Blog Archives
All Blog Posts

2010
    November (1)
2009
    July (2)
    February (2)
    January (1)
2008
    December (1)
    October (3)
    June (1)
    April (3)
    February (1)
    January (1)
2007
    December (1)
    October (2)
    September (2)
    July (1)
    June (2)
    May (4)
    April (6)
    March (8)
    February (3)
    January (2)
2006
    December (2)
    November (2)

 

 

 

This Blog is powered by MilosTM Collaboration Components.