简体   繁体   中英

Entity framework some simple questions

I'm quite new to Entity Framework and want to catch a grasp on how some things should be done properly. I have 2 tables:

  1. Person defined with PersonId, Name, Address, Phone, Nip, Email
  2. Client defined with ClientId, Comment, Special Information, Product, PersonID

Client is connected with Person by PersonID. Now I want to display it in ListView showing only ClientName (so JOIN with PERSON - Person.Name) and Client.Comment.

Then user will be able to double click on that Client and this will bring him to edit window with all Person Details that he will be able to change.

How this should be done? I thought about creating one of:

Creating view_ which will only give me 4 columns (4 with ClientID, PersonID, Person.Name, Client.Comment)

IQueryable<view_KlienciList> klientQuery1 = from d in  crmEntities.view_KlienciList select d;`

var klientQuery1 = context.view_KlienciList.Select(d => new { Nazwa = d.Nazwa
                                                                      });

Doing a select with just some columns

IQueryable<Klienci> klientQuery = from d in crmEntities.Kliencis.Include("Podmioty")
                                  select d (......)

So which is better and why should I go this way? Considering that when user double clicks on user again I will have to load all columns from Client,Person for that selected person.

第二个功能取消了延迟加载功能,但在某些情况下有其优点。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM