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
Samio
NA
201
176.4k
LINQ to Entities Small code to test data retrieval C# WinForms
Mar 19 2012 6:37 PM
Hi
Could not get this to work, When I Run project no console is displayed
also as I am new to Entity Framework with C# winforms, I would like to ask how to fill a TextBox with a context item.
I am using Visual studio 2010 version and MS SQL 2008 Express.
Thank you
Code:
using System;
using System.Data.Objects;
using System.Linq;
using System.Windows.Forms;
namespace MyNameSpace
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void BtnOk_Click(object sender, EventArgs e)
{
using (LINQtoEntitiesEntities MyEntities = new LINQtoEntitiesEntities())
{
ObjectQuery<Employee> Employee = MyEntities.Employee;
var query = from p in Employee
where p.FirstName == "Jane"
select new { p.ID, p.LastName, p.FirstName, p.Birth };
foreach (var ligne in query)
Console.WriteLine(ligne.ID + " " + ligne.LastName + " " + ligne.FirstName);
}
Console.Read();
}
}
}
Reply
Answers (
13
)
Nested GroupBy extension method
LINQ to Entities - How to retrieve a data and use it as a variable in the whole project