Skip to content

Instantly share code, notes, and snippets.

@okaram
Created November 17, 2012 15:47
Show Gist options
  • Save okaram/4096944 to your computer and use it in GitHub Desktop.
Save okaram/4096944 to your computer and use it in GitHub Desktop.
LinQ basics
protected void AddBlog_Click(object sender, EventArgs e)
{
SimpleBlogDataContext ctx = new SimpleBlogDataContext();
Blog b = new Blog();
b.Title = BlogTitle.Text;
ctx.Blogs.InsertOnSubmit(b);
try
{
ctx.SubmitChanges();
}
catch (Exception e1)
{
Console.WriteLine(e1);
}
}
<%@ Import namespace="System.Linq" %>
SimpleBlog.SimpleBlogDataContext ctx = new SimpleBlog.SimpleBlogDataContext();
var blogs = from b in ctx.Blogs
select b;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment