Logo video2dn
  • Сохранить видео с ютуба
  • Категории
    • Музыка
    • Кино и Анимация
    • Автомобили
    • Животные
    • Спорт
    • Путешествия
    • Игры
    • Люди и Блоги
    • Юмор
    • Развлечения
    • Новости и Политика
    • Howto и Стиль
    • Diy своими руками
    • Образование
    • Наука и Технологии
    • Некоммерческие Организации
  • О сайте

Скачать или смотреть Part 16 Self referencing association in entity framework

  • kudvenkat
  • 2014-06-02
  • 54446
Part 16   Self referencing association in entity framework
self referencingassociationentity frameworkdatabase firsttutorialtable
  • ok logo

Скачать Part 16 Self referencing association in entity framework бесплатно в качестве 4к (2к / 1080p)

У нас вы можете скачать бесплатно Part 16 Self referencing association in entity framework или посмотреть видео с ютуба в максимальном доступном качестве.

Для скачивания выберите вариант из формы ниже:

  • Информация по загрузке:

Cкачать музыку Part 16 Self referencing association in entity framework бесплатно в формате MP3:

Если иконки загрузки не отобразились, ПОЖАЛУЙСТА, НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если у вас возникли трудности с загрузкой, пожалуйста, свяжитесь с нами по контактам, указанным в нижней части страницы.
Спасибо за использование сервиса video2dn.com

Описание к видео Part 16 Self referencing association in entity framework

Text version of the video
http://csharp-video-tutorials.blogspo...

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
   / @aarvikitchen5572  

Slides
http://csharp-video-tutorials.blogspo...

Entity Framework - All Text Articles
http://csharp-video-tutorials.blogspo...

Entity Framework - All Slides
http://csharp-video-tutorials.blogspo...

Entity Framework Playlist
   • Entity Framework Tutorial  

Dot Net, SQL, Angular, JavaScript, jQuery and Bootstrap complete courses
https://www.youtube.com/user/kudvenka...


In this video, we will discuss self referencing association in entity framework with database first approach. Let us understand self-referencing association with an example.

We will be using Employees table in this demo. This table is a self-referencing table because to get the manager of an employee, we take ManagerId column value and look up in the EmployeeId column of the same table.

Now if you generate an ADO.NET entity data model based on this Employees table, Employee entity is generated. Notice that a self-referencing association and 2 navigation properties (Employees1 & Employee1) are automatically created.

Right click on Employees1 navigation property and select properties. In the properties window notice that the Multiplicity is set to Many. So, this navigation property returns employees who are subordinates.

Similarly, right click on Employee1 navigation property and select properties. In the properties window notice that the Multiplicity is set to Zero or One. So, this navigation property returns the manager of an employee.

From a developer perspective these navigation property names are difficult to understand. If you have to write any code based on these navigation properties, it can get even more complicated. For example, let us say we want to display Employee names and their respective manager names.

To achieve this we would drag and drop a GridView control on the webform and write the following code in the code-behind file Page_Load event. Notice that, because of the poor naming of the navigation properties the code is hard to read and maintain.
protected void Page_Load(object sender, EventArgs e)
{
EmployeeDBContext employeeDBContext = new EmployeeDBContext();
GridView1.DataSource = employeeDBContext.Employees.Select(emp =] new
{
EmployeeName = emp.EmployeeName,
ManagerName = emp.Employee1 == null ? "Super Boss" : emp.Employee1.EmployeeName
}).ToList();
GridView1.DataBind();
}

Now let's give these navigation properties meaningful names. To do this,
1. Right click on Employees1 navigation property and rename it to Subordinates
2. Similarly, right click on Employee1 navigation property and rename it to Manager

Now the code in the code-behind file would change as shown below which is more readable and maintainable.
protected void Page_Load(object sender, EventArgs e)
{
EmployeeDBContext employeeDBContext = new EmployeeDBContext();
GridView1.DataSource = employeeDBContext.Employees.Select(emp =] new
{
EmployeeName = emp.EmployeeName,
ManagerName = emp.Manager == null ? "Super Boss" : emp.Manager.EmployeeName
}).ToList();
GridView1.DataBind();
}

Комментарии

Информация по комментариям в разработке

Похожие видео

  • О нас
  • Контакты
  • Отказ от ответственности - Disclaimer
  • Условия использования сайта - TOS
  • Политика конфиденциальности

video2dn Copyright © 2023 - 2025

Контакты для правообладателей [email protected]