c# - Retrieve single Entity Framework entities using a LINQ query or GetObjectKey? -


It seems that GetObjectKey has the advantage of searching for an existing, instant object, and then store data. However, it also seems that you lose some strong typing, and your resultant object is required to be inserted:

GetObjectKey

  int customerID = 1; EntityKey key = New EntityKey ("MyEntities.Customers", "CustomerID", customerID); Customer Customer = Reference Gate Objectbike (key) as a customer;  

vs. LINQ

  Integer Customer ID = 1; Customer customer = (In the context of C-customers, select c.CustomerID = customerID c). Before and after default ();  

Personally, I like the latter method due to typing.

What do you use boys and girls?

In addition, your DAL is the only commonality in conjunction with all available methods, though this is a personal preference.

I like the latter because it is clearly clear what you want. By using EntityKey (and it is something that the ADO .Net team does not understand), we have to work around the structure we imposed by the organization framework. Using the query language you have done in the second example, we are telling the rest of the developers who will ever see our code, we want this object from this ID or we want it to be empty. / P>

I do not think that being right (as you are in the first example) is an excuse not to explain to your colleagues. :)


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -