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
dc
NA
663
0
Is this linq to sql code to update table ok?
Nov 11 2011 3:41 PM
I would like to know if the following code is written ok or is there a better way? If there is a better way, can you explain and/or point me to a reference I can use? Is the linq writing from one datacontext object to some data fields ok? Also is the try catch adequate?
I do know the code works since I stepped through the code.
I am asking the question is this is my first time working with linq to sql in a C# 2010 application and I am the only programmer at my company.
protected void Ready_Data(Attes att, AtsDataContext attDataContext)
{
try {
var results = from s in attDataContext.Attes_Schedules
where s.Pay_Month == att.Pay_Month_Date
select new
{
PayDate = s.Pay_Month,
CurCStopDate = s.Current_C_Stop_Date,
PriorCStopDate = s.Prior_C_Stop_Date,
RptsReceviedMonth = s.Rpts_Rec_Month,
};
foreach (var r in results)
{
att.Pay_Month_Date = r.PayDate;
att.Current_C_Stop_Date = r.CurCStopDate;
att.Prior_C_Stop_Date = r.PriorCStopDate;
att.C_Rpts_Rec_Date = r.RptsReceviedMonth;
}
}
catch (Exception ex)
{
lblErrorMsg.Text = "Attes Page Processing problem";
lblErrorMsg.Visible = true;
hold_Exception = ex;
}
}
Reply
Answers (
1
)
How to draw a tree graph
C# using ints in Textbox.Visible