Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.LINQDataAccess/3.3/ClientConfigDao.cs @ 4092

Last change on this file since 4092 was 4092, checked in by cneumuel, 14 years ago

replaced transaction- and context management from Spring-advice by custom context management (see ContextFactory) (#1098)

File size: 2.1 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Hive.Contracts.BusinessObjects;
6using HeuristicLab.Hive.Server.DataAccess;
7
8namespace HeuristicLab.Hive.Server.LINQDataAccess {
9  public class ClientConfigDao: BaseDao<ClientConfigDto, ClientConfig>, IClientConfigDao {
10
11    #region IGenericDao<ClientConfigDto,ClientConfig> Members
12
13    public ClientConfigDto FindById(Guid id) {
14      return (from cc in Context.ClientConfigs
15              where cc.ClientConfigId.Equals(id)
16              select EntityToDto(cc, null)).SingleOrDefault();
17    }
18
19    public IEnumerable<ClientConfigDto> FindAll() {
20      return (from cc in Context.ClientConfigs             
21              select EntityToDto(cc, null)).ToList();
22    }
23
24    public ClientConfigDto Insert(ClientConfigDto bObj) {
25      ClientConfig c = DtoToEntity(bObj, null);
26      Context.ClientConfigs.InsertOnSubmit(c);
27      CommitChanges();
28      bObj.Id = c.ClientConfigId;
29      return bObj; 
30    }
31
32    public void Delete(ClientConfigDto bObj) {
33      Context.ClientConfigs.DeleteOnSubmit(Context.ClientConfigs.SingleOrDefault(c => c.ClientConfigId.Equals(bObj.Id)));
34      CommitChanges();
35    }
36
37    public void Update(ClientConfigDto bObj) {
38      ClientConfig cc = Context.ClientConfigs.SingleOrDefault(c => c.ClientConfigId.Equals(bObj.Id));
39      DtoToEntity(bObj, cc);
40      CommitChanges();
41    }
42
43    #endregion
44
45    public override ClientConfig DtoToEntity(ClientConfigDto source, ClientConfig target) {
46      if (source == null)
47        return null;
48      if (target == null)
49        target = new ClientConfig();
50
51      target.ClientConfigId = source.Id;
52      target.HeartBeatIntervall = source.HeartBeatIntervall;
53     
54      return target;
55    }
56
57    public override ClientConfigDto EntityToDto(ClientConfig source, ClientConfigDto target) {
58      if (source == null)
59        return null;
60      if (target == null)
61        target = new ClientConfigDto();
62
63      target.Id = source.ClientConfigId;
64      target.HeartBeatIntervall = source.HeartBeatIntervall;
65
66      return target;
67
68    }
69  }
70}
Note: See TracBrowser for help on using the repository browser.