Re: passing objects into methods that do database processing?

Tech-Archive recommends: Fix windows errors by optimizing your registry



I am working on a news section of a website. This section will be able to
add, edit and delete news articles from the database. Right now I have a
NewsHelper class that does all of the database work for the news sections of
the website. At this point the NewsHelper class has The methods GetNews,
NewsCount, GetNewsByNewsID, GetNewsByCategoryId, GetCategoryCount,
GetCategoriesByNewsID and so on. Anyways, What I need to do is take
something that represents a newsItem and insert the whole thing into the
database along with cross referencing the news article with the categories
it goes under in the NewsHeaders table. I have a dll called News that has
the helper class and probably the NewsItem object or data type depending how
things should go. This is what the NewsItem object looks like:
NewsID - identity(1,1) int (the NewsID number).
Date - DateTime (The date/time the news article was posted).
Title - varchar(50) [will probably change to varchar(MAX)] (The news article
title/subject line).
Text - Text (the body of the news article).
Categories - a <List>Categories colllection of the categories the news
article is filed under. The categories list is under a different database
table than the other properties of the news article.

What I need to do is go through this object and make sure that everything is
done right and then put it in the database. Any ideas on how this should be
done? I am hoping to be able to reuse the NewsItem object (or whatever it is
I should use) and the NewsHelper class in a different project. I eventually
plan on making a winforms program that will be able to update the website
and stuff as well. So, most of this code should be reusable. Any advise is
helpful on how I should do this...


"Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:O7mAcEHLIHA.3916@xxxxxxxxxxxxxxxxxxxxxxx
Andy,

I don't think it is bad practice, but I wouldn't say that you start to
look into passing everything as an object. What exactly are you trying to
pass into the database, and why?


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"Andy B" <a_borka@xxxxxxxxxxxxx> wrote in message
news:eRWtLrGLIHA.4712@xxxxxxxxxxxxxxxxxxxxxxx
Is it good (or should I say normal) practice to pass an object into a
method for database processing? Or should I stay away from that sort of
thing.







.



Relevant Pages

  • Re: NModifiable News/Articale Manager?
    ... All I really want to do is create a few extra fields in the existing news ... > that news article: ... > Now all the info should be in the database, and you have to call on it. ...
    (alt.php)
  • Re: Dabbling in plain-text databases
    ... plain-text databases (and if they're worth using in lieu of sql). ... will be sort of a video game fansite, that will have a news page (news ... parsing a file like that any faster or slower than using MySQL? ... An sql based database is better for situations requiring  better ...
    (comp.lang.php)
  • Re: OT: Bad News for Republicans
    ... a news article from the formerly respected venerable old AP. ... About as many approve of his handling of Iraq, ... About a third of the public, 34 percent, approves of the job Congress ...
    (rec.gambling.poker)
  • Re: Dabbling in plain-text databases
    ... plain-text databases (and if they're worth using in lieu of sql). ... will be sort of a video game fansite, that will have a news page (news ... parsing a file like that any faster or slower than using MySQL? ... An sql based database is better for situations requiring better ...
    (comp.lang.php)
  • Re: COMMENT FORM
    ... comment form on something like a blog or news article, is using addslashesall that is needed to prevent unwanted malicious user data? ... No. addslashes() is hardly ever necessary. ... It is, but not very likely to hit you, it's a combination of a rare database setup combined with a particular encoding/unicode-charaters that might get through this. ... Heel o, unless the slashes are magiacally added, no adding of deleting of slashes is required. ...
    (comp.lang.php)