जब एक इकाई ढांचे संदर्भ शुरू करें। अन्य तरीके से इस तरह केएक इकाई ढांचे संदर्भ शुरू करने के लिए सबसे अच्छा तरीका है?
public class EntityContactManagerRepository
: ContactManager.Models.IContactManagerRepository
{
private ContactManagerDBEntities _entities = new ContactManagerDBEntities();
// Contact methods
public Contact GetContact(int id)
{
return (from c in _entities.ContactSet.Include("Group")
where c.Id == id
select c).FirstOrDefault();
}
}
के रूप में विधि स्तर पर प्रारंभ करने में है
एक, श्रेणी स्तर पर प्रारंभ करने में है।
public class EntityContactManagerRepository
: ContactManager.Models.IContactManagerRepository
{
// Contact methods
public Contact GetContact(int id)
{
using (var entities = new ContactManagerDBEntities())
return (from c in entities.ContactSet.Include("Group")
where c.Id == id
select c).FirstOrDefault();
}
}
एक Ado.Net पृष्ठभूमि से, मैं बाद में एक को प्रारंभ में विधि पसंद करते हैं, लेकिन पहले एक Stephen Walthe द्वारा विकसित उदाहरण से है। या एक और सवाल, क्या यह बिल्कुल मायने रखता है?
लिंक मर चुका है ... – Jude