Shamil Salakhetdinov
shamil at smsconsulting.spb.ru
Tue Oct 13 14:26:44 CDT 2009
Hi John,
You can use XMlArray attribute to define the name of XML group of serialized
arrays, collections, lists,..
http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlattribut
es.xmlarray.aspx
BTW, guys and gals, I'm programming on C# every day - I forgot when I last
time used DataSets typed or not, well, that could be specifics of my subject
area, but for example for a large ASP.NET site I developed, multi-layered
with several thousands of custom classes etc. , DataSets were not used at
all - and that large ASP.NET site is a business application with MS SQL 2005
backend...
Just out of curiosity I have just checked DotNetNuke Community Edition 5.1.4
sources
http://dotnetnuke.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=33848
to find out how much times DataSet is used in these sources - here is my
search result:
===
Matching lines: 22
Matching files: 5
Total files searched: 1414
===
--
Shamil
-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Tuesday, October 13, 2009 8:13 PM
To: Discussion concerning Visual Basic and related programming issues.
Subject: Re: [dba-VB] C# serialization
> Of course, I can see an educational purpose by handcrafting a kind of
database, but ...
LOL. Well, this is after a CLASS in C# the purpose of which is to LEARN C#.
You do not start at
typed data sets, you start with "this is a variable" and "this is a for
loop". I am very much at
that level.
I am quite sure that in a year I will be throwing out typed datasets with
the best of them but right
now I am still forgetting to put a ; at the end of the line.
Have patience Master #2.
John W. Colby
www.ColbyConsulting.com
Gustav Brock wrote:
> Hi John
>
> Sounds like a quite normal database app to me ...
>
> If so, all the typed dataset stuff is ready at your hands.
> To persist (to an XML file without the overhead you claim about) use
method WriteXml.
> To read it at load, use method ReadXml. Can't be simpler.
>
> Of course, I can see an educational purpose by handcrafting a kind of
database, but ...
>
> /gustav
>
>
>>>> jwcolby at colbyconsulting.com 13-10-2009 17:37 >>>
> >Do these classes inherit typed datasets?
>
> Nope, no connection to a database.
>
> The original assignment was to build a grade calculator where you simply
input a list of grades.
> There are three types of grades, each with a different weight (Tests - 40%
of grade, Labs - 50% of
> grade and DL 10% of grade).
>
> There is no requirement to do anything more than the above, calculating a
total count of each grade
> type, sum of each type, average of each type and weighted average of each
type, and then the same
> calculations for the totals.
>
> In order not to be bored to death, and with the approval of the
instructor, I expanded the
> assignment to include using classes and collections. I store each grade
in an instance of clsGrade.
> I store all of each TYPE of grade in an instance of clsGrades (plural)
which contains a generic
> collection into which the instances of clsGrade are inserted. This
collection is strongly typed so
> that it can only accept clsGrade objects.
>
> Each instance of clsGrades (plural) is inserted into a sorted list in
clsCalculator, keyed on
> GradeType (keyed on the string "Test", "Lab" or "DL"). In the main form
there is a combo with three
> grade type strings ("Test", "Lab" and "DL") which when selected is passed
in to clsCalculator which
> indexes into the collection to access the correct instance of clsGrades.
Adding new grades,
> deleting grades and updating existing grades is all done on the selected
instance of clsGrades.
>
> So...
>
> clsCalculator - interfaces to the form and has a sorted collection holding
three instances of...
> clsGrades - contains a strongly typed generic collection holding multiple
instances of ...
> clsGrade - contains each grade.
>
> clsGrades performs the calculations to count (collection.count), sum,
average and weighted average
> all of the grades contained within.
>
> clsCalculator requests the various computed values from the three
instances of clsGrades and
> performs the calculations to create an overall Count (sum of
clsGrades.Count), Sum (sum of
> clsGrades.Sum), Average, weighted sum etc.
>
> Now...
>
> I want to write the grades in each clsGrades instance to a single file,
then read it back in again.
> Persist the grades to disk. I have no requirement to persist the data
to disk, I simply want to
> do so.
>
> Please please please do not suggest a "better way" for doing the
assignment, it is all written and
> functions exactly as you would expect it to work. You may of course
enlighten me on different
> options, but I will not be rewriting the core assignment at this point.
>
> This was just a homework assignment and it is in fact finished. If I can
persist it great, if not
> that's OK too. I have learned a lot and thought I might learn how to do
the persist thing, streams,
> serialization (if that is used) etc. Even classes and collections are a
"next semester" thing so I
> am ahead of the curve at this point.
>
> John W. Colby
> www.ColbyConsulting.com
>
>
> Charlotte Foust wrote:
>> John,
>>
>> I'm not sure I understand what you're doing. Do these classes inherit
>> typed datasets? If so, the parent class can easily return a child class
>> that already contains a typed dataset of child records. You don't
>> actually need collections for that. In that case, grade wouldn't need
>> to be a class (although it could be, I just don't see any need). The
>>
>> Charlotte Foust
>
__________ Information from ESET NOD32 Antivirus, version of virus signature
database 4504 (20091013) __________
The message was checked by ESET NOD32 Antivirus.
http://www.esetnod32.ru