Josh-CO Dev

Solving the worlds problems one line of code at a time.

Some LinqToSQL Samples to get you through the day

Leave a comment


So, one of the things that I am learning from scratch with Silverlight is LinqToSQL. In my professional life, we are still using typed datasets to do all of our databinding and our restricted to WinForms and ASP.net. So this is all new to me. I have found the process to be incredibly simple and thought I would share some code.

Click past the jump for code.

Selecting a rowset…

DataContext context = new DataContext();

var result = from users in context.CrossfitUserInfos

select users;

return result.ToList();

Inserting a new row…

DataContext context = new DataContext();

tableName newInfo = new tableName ()

{

     UserID = userid,

     FirstName = fname,

     LastName = lname,

     Email = email,

     Created = System.DateTime.Now

};

context.tableName.InsertOnSubmit(newInfo);

context.SubmitChanges();

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s