TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Olivier Muhring
1.5k
262
9.2k
Trace logging with nLog (or similar) - how to deal with null
May 3 2018 5:12 AM
I recently started on a contract role.
The idea is to take full ownership of a bunch of applications. Since there is virtually no technical documentation I've been going through the code, and adding trace logging (with NLog) where it seems appropriate.
A lot of the code however consists of the execution of stored procs and simply passing through dataset objects, like this:
Factory.GetArchiveDataAccess().NothandledUpdate(AppSetting.StatusArchive.StatusNotHandled.GetHashCode(), Machine.DecConfigId);
NewArchives.NewArchivesDataSet = Factory.GetArchiveDataAccess().NewArchives().ResultSet;
// Trace
if
(NewArchives.NewArchivesDataSet !=
null
&& NewArchives.NewArchivesDataSet.Tables.Count > 0)
{
_logger.Trace($
"Returns {NewArchives.NewArchivesDataSet.Tables[0].Rows.Count}"
);
}
else
{
_logger.Trace(
"NewArchives.NewArchivesDataSet does not contain data"
);
}
At the moment, when I want to show if a strored proc found data or not I'm forced to add a bunch of tests to avoid exceptions.
Isn't there a cleaner way of achieving this?
Reply
Answers (
2
)
I need to Create Leave approval system in C# and sql.
WEB API with ADFS Authentication