How this new Visual Studio 2010 looks like? This has three views. Here it is,
Start Page > Welcome
Start Page > Projects
Start Page > Visual Studio
Namoskar!!!
I am super excited to see Anders demonstrating C# 4.0 for first time in public. I am a real fan of him and downloaded the public bit to tryout. Here is my first Dynamic C# 4.0 program.
There is nothing much to be excited from my Program but I am very much after hitting F5.
static void Main(string[] args)
{
dynamic i = 10;
dynamic sHello = "Hello C# 4.0";
Console.WriteLine(i);
Console.WriteLine(sHello);
}
More to come.
If you are thinking that you are a looser not by attending PDC 2008, forget it. Stretch your body as you might to stay connected to your chair for long time.
What is
and many more.. So without wasting time join and view the video, download them.
https://sessions.microsoftpdc.com/
https://sessions.microsoftpdc.com/public/timeline.aspx
For you to design the better future.
Link to download http://www.codeplex.com/AppArchGuide
Relationship and getting data from Entity Framework using Northwind database
Simple Query
using (NorthwindEntities ctx = new NorthwindEntities())
var query = from o in ctx.Orders
select o.OrderID;
foreach (var k in query)
Console.WriteLine(k);
Now if you want to filter this with the parent information,
where o.Customers.City == "London"
This actually goes one level up and then filters the data.
Include Child Information
var query = from c in ctx.Customers
where c.City == "London"
select c;
Console.WriteLine(k.ContactName);
Now if you want to get the “Orders” table, there are two ways to do it,
Immediate Loading
var query = from c in ctx.Customers.Include("Orders")
Console.WriteLine(k.Orders.Count);
On-Demand Loading
//if not loaded then load it
if (!k.Orders.IsLoaded)
k.Orders.Load();
Get your MSDN magazine from web at http://msdn.microsoft.com/msdnmag/.
Few days back I had written an article on Insert/Update/Delete for simple standalone tables at ADO.NET Entity: Insert Update and Delete. Now after that many of you had requested me to put article on how it works with relationship.
Here I will use a database created by me. There will be two tables connected with each other.
Now I will create TestDB.edmx out of this database.
Insert
using (TestDBEntities ctx = new TestDBEntities())
//Create new Department
Dept d = new Dept() { DeptName = "ADO Entity" };
//Create new Employee 1
EmpDept ed1 = new EmpDept() { EmpName = "ADO Employee 1" };
//Create new Employee 2
EmpDept ed2 = new EmpDept() { EmpName = "ADO Employee 2" };
//Add employee to the Dept *OBJECT*
d.EmpDept.Add(ed1);
d.EmpDept.Add(ed2);
//Updating the context
ctx.AddToDept(d);
//Save to Database
ctx.SaveChanges();
Update
//Get an existing Department
Dept dep = (from d in ctx.Dept
where d.DeptId == 22
select d).First();
//Set new Department name
dep.DeptName = "ADO.NET 3.0";
EmpDept ed2 = new EmpDept() { EmpName = "ADO 2" };
//Add *new* employee to the Dept *OBJECT*
dep.EmpDept.Add(ed2);
Delete
Dept dep = (from d in ctx.Dept.Include("EmpDept")
/*
Needd to do ToList() becuase once you delete
a record then iteration will not be possible.
*/
foreach (EmpDept ed in dep.EmpDept.ToList())
//This removes relationship from Context
dep.EmpDept.Remove(ed);
//Delete it from context
ctx.DeleteObject(ed);
//Delete the master table
ctx.DeleteObject(dep);
Note: during delete you first need to remove the relationship from entity and then delete the object from entity. So you need to keep the child data offline and then do operation. Then delete the main object.
In my next post I will write about “how to select with Relationship”.
Know more about it and keep you sink with http://msdn.microsoft.com/en-us/vstudio/products/cc948977.aspx
What's New
Additional Resources