Entity

Topics: Microsoft SQL Server, Articles with example SQL code, .NET Framework Pages: 2 (267 words) Published: April 30, 2014
Tutorial Entity Framework

Create database in SQL Server and call it Company. Login is sa password: r00m215 Execute script company_sqlserver.sql that you could download from module web site that will create EMP and DEPT tables. These tables we will use to implement CRUD operations using Entity Framework. Using examples specified below implement the following pages: Page that will show all the employees

Page that will show all the employees filtered by Job
Page where you will be able to insert or update new employee Page where you will be able to delete employee by EmpNo
Create tables that we used for Library case study in SQL Server DB and implement Lbrary system using Entity Framework. Entity Framework Examples
Select
//getting list of objects
using (var ctx = new ChinookEntities())
{
var res = from e in ctx.Employees
where e.City == city
select e;
return res.ToList();
}
//getting one object
using (var ctx = new ChinookEntities())
{
var res = from e in ctx.Employees
where e.EmployeeId == id
select e;
return res.FirstOrDefault();
}
//alternative syntax
using (var ctx = new ChinookEntities())
{
var res = ctx.Employees.Where(e=>e.EmployeeId == id).FirstOrDefault(); return res;
}
//get employees wth customers loaded
using (var ctx = new ChinookEntities())
{
var res = ctx.Employees
.Where(e => e.City == city).Include(e=>e.Customers).ToList(); return res;
}
Insert
using (var ctx = new ChinookEntities())
{
ctx.Genres.Add(g);
ctx.SaveChanges();
}

Update
using (var ctx = new ChinookEntities())
{...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • The Entity Relationship Diagram. Essay
  • Draw the Entity 1 1 Essay
  • Essay on Huffman Trucking Entity-Relationship Model
  • Entities and Attributes for Fleet Truck Maintenance Essay
  • Entity relationship diagram on the use of different types of modeling such as conceptual and logical Essay
  • Entity-relationship Model and Mountain View Community Research Paper
  • Essay on Database Models: Entity Relationship Modeling
  • company a separate legal entity Essay

Become a StudyMode Member

Sign Up - It's Free