Search Results

Search found 2 results on 1 pages for 'mindlessprogrammer'.

Page 1/1 | 1 

  • Linq to sql Repository pattern , Some doubts

    - by MindlessProgrammer
    I am using repository pattern with linq to sql, I am using a repository class per table. I want to know , am i doing at good/standard way, ContactRepository Contact GetByID() Contact GetAll() COntactTagRepository List<ContactTag> Get(long contactID) List<ContactTag> GetAll() List<ContactTagDetail> GetAllDetails() class ContactTagDetail { public Contact Contact {get;set;} public ContactTag COntactTag {get;set;} } When i need a contact i call method in contactrepository, same for contacttag but when i need contact and tags together i call GetDetais() in ContactTag repository its not returning the COntactTag entity generated by the orm insted its returning ContactTagDetail entity conatining both COntact and COntactTag generated by the orm, i know i can simple call GetAll in COntactTag repository and can access Contact.ContactTag but as its linq to sql it will there is no option to Deferred Load in query level, so whenever i need a entity with a related entity i create a projection class Another doubt is where i really need to right the method i can do it in both contact & ContactTag repostitory like In contact repository GetALlWithTags() or something but i am doing it in in COntactTag repository Whats your suggestions ?

    Read the article

  • LINQ2SQL DataLayer / Repository Suggestion

    - by MindlessProgrammer
    My current respository is as follows , please suggest , i am currently using LINQ2SQL Data context per insert/delele/update namespace Lib.Repository { public class MotorRenewalDataRepository { public MotorRenewalDataRepository() { } public MotorRenewalData GetByID(long id) { using(var _context=DatabaseFactory.Create(false)) { return _context.MotorRenewalDatas.Where(p => p.MotorRenewalDataID == id).FirstOrDefault(); } } public MotorRenewalData Insert(MotorRenewalData entity) { using (var _context = DatabaseFactory.Create(false)) { _context.MotorRenewalDatas.InsertOnSubmit(entity); _context.SubmitChanges(); return entity; } } public void Update(MotorRenewalData entity) { using (var _context = DatabaseFactory.Create(true)) { var dbEntity = _context.MotorRenewalDatas.Where(p => p.MotorRenewalDataID == entity.MotorRenewalDataID) .FirstOrDefault(); Common.CopyObject<MotorRenewalData>(entity, dbEntity); _context.SubmitChanges(); } } } }

    Read the article

1