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
Gaurav Raj
NA
475
88.7k
how can convert this code into linq format
Oct 25 2018 1:24 AM
//Here we will add a function for register notification (will add sql dependency)
public
void
RegisterNotification(DateTime currentTime)
{
string
conStr = ConfigurationManager.ConnectionStrings[
"sqlConString"
].ConnectionString;
string
sqlCommand = @
"SELECT [ContactID],[ContactName],[ContactNo] from [dbo].[Contacts] where [AddedOn] > @AddedOn"
;
//you can notice here I have added table name like this [dbo].[Contacts] with [dbo], its mendatory when you use Sql Dependency
using
(SqlConnection con =
new
SqlConnection(conStr))
{
SqlCommand cmd =
new
SqlCommand(sqlCommand, con);
cmd.Parameters.AddWithValue(
"@AddedOn"
, currentTime);
if
(con.State != System.Data.ConnectionState.Open)
{
con.Open();
}
cmd.Notification =
null
;
SqlDependency sqlDep =
new
SqlDependency(cmd);
sqlDep.OnChange += sqlDep_OnChange;
//we must have to execute the command here
using
(SqlDataReader reader = cmd.ExecuteReader())
{
// nothing need to add here now
}
}
Reply
Answers (
4
)
Automatically Video play in chat bot
Implement DropdownlistFor Using Code First . MVC