Monday, August 25, 2008

XML Serialization




Nice article about how to Serialize and DeSerialize objects in XML.http://www.dotnetfunda.com/articles/article98.aspx. This is really handy when you want to make saving objects very versatile and not database dependent. Below is a list of additional reasons to use XML Serialization.

  • Storing user preferences in an object.
  • Maintaining security information across pages and applications.
  • Modification of XML documents without using the DOM.
  • Passing an object from one application to another.
  • Passing an object from one domain to another.
  • Passing an object through a firewall as an XML string.
  • Source (http://www.dotnetjohn.com/articles.aspx?articleid=173)

To make objects serializable, I create an XSD schema that represents my object. You know, contract first, then code last.




Then I use a code generator that will generate a .NET class that makes my object XML serializable. Its called XSD Object Generator which is a plug in for Visual Studio. You can download the tool from here: http://weblogs.asp.net/jdanforth/archive/2004/09/18/231209.aspx.

Then you can create a XML serializer and deserializer helper classes. These classes will take an object in memory and serialize it to an XML stream or hydrate a XML stream to an object. I usually hook in a Database helper class and save the XML string to the database for later use.


Have fun! Let me know if this makes sense.





Wednesday, August 13, 2008

Samsung Instinct Phone Updates


All,


If any of you out there have the Samsung Instinct then you will be happy to here that Sprint is pushing updates to the Visual Voice Mail and Sprint TV applications today.


I don't know what the differences are yet. When I find out I will update this post.


Enjoy the Instinct. I know I am.

Thursday, August 7, 2008

SQL 2008 is Released!!!!






SQL Server 2008 is one of Microsoft's best products ever. Me personally, I love it. Its fast, scalable, developer friendly (unlike Oracle), and worry free.

For a comprehensive list of new features and changes read this blog: http://blogs.msdn.com/chadboyd/archive/2007/07/26/katmai-sql-2008-the-list-of-new-features.aspx.



To learn more about SQL Server 2008 visit the TechNet site: http://technet.microsoft.com/en-us/magazine/cc434690.aspx.

Tuesday, August 5, 2008

.NET DataTable Select Experssions

Sometimes I like to get raw data from a database table and select information from it through .NET code. I use the SELECT() method and pass it an expression. The problem is I never remember what types of expressions are valid. So I am listing them here as I come across them. One thing to remeber. If your column names have spaces, use brackets around the column name.

*Column name with spaces
string filter = "[job grade] = '" + jobGradeRowsToUpDate[j]["JobGrade"].ToString() + "'";

* NOT IN (item 1,item 2,...)
DataRow[] jobGradeRowsToDelete = currentJobGradeData.Select("jobgrade NOT IN (" + newJobGradeID + ")");

* not equal <>
DataRow[] jobGradeRowsToDelete = currentJobGradeData.Select("jobgrade <> '1'");

Other
Expression Operators
The list of supported operators is somewhat small:

Math Operators:

+ (addition)
- (subtraction)
* (multiplication)
/ (division)
% (modulus, the remainder after division)
String Operator:

+ (concatenation, joining strings)
Comparison Operators:

< (less than) > (greater than)
<= (less than or equal to) >= (greater than or equal to)
<> (not equal to)
= (equal)
IN (compare to a list of items)
LIKE (pattern matching)
Scalar Functions:

Convert (change from one data type to another)
Len (return the length of the string)
IsNull (test for null)
IIf (Immediate If)
Trim (trim white space from string)
Substring (return a part of a string)
Aggregation Functions:

Sum (Sum)
Avg (Average)
Min (Minimum)
Max (Maximum)
Count (Count)
StDev (Standard deviation)
Var (Statistical variance)

**Source: http://home.hot.rr.com/graye/Articles/ADO_Expressions.htm