Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/ClientConfigDao.cs @ 3011

Last change on this file since 3011 was 3011, checked in by kgrading, 14 years ago

changed the complete DAL to LINQ 2 SQL (with the exception of the job streaming), did a lot of refactoring, Introduced DTOs (that are named DTOs for better understanding), added the spring.NET Interceptor, reintroduced transactions and cleaned up the whole JobResult thing and updated a part of the config merger (#830)

File size: 2.2 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
12    #region IGenericDao<ClientConfigDto,ClientConfig> Members
13
14    public ClientConfigDto FindById(Guid id) {
15      return (from cc in Context.ClientConfigs
16              where cc.ClientConfigId.Equals(id)
17              select EntityToDto(cc, null)).SingleOrDefault();
18    }
19
20    public IEnumerable<ClientConfigDto> FindAll() {
21      return (from cc in Context.ClientConfigs             
22              select EntityToDto(cc, null)).ToList();
23    }
24
25    public ClientConfigDto Insert(ClientConfigDto bObj) {
26      ClientConfig c = DtoToEntity(bObj, null);
27      Context.ClientConfigs.InsertOnSubmit(c);
28      Context.SubmitChanges();
29      bObj.Id = c.ClientConfigId;
30      return bObj; 
31    }
32
33    public void Delete(ClientConfigDto bObj) {
34      Context.ClientConfigs.DeleteOnSubmit(Context.ClientConfigs.SingleOrDefault(c => c.ClientConfigId.Equals(bObj.Id)));
35      Context.SubmitChanges();
36    }
37
38    public void Update(ClientConfigDto bObj) {
39      ClientConfig cc = Context.ClientConfigs.SingleOrDefault(c => c.ClientConfigId.Equals(bObj.Id));
40      DtoToEntity(bObj, cc);
41      Context.SubmitChanges();
42    }
43
44    #endregion
45
46    public override ClientConfig DtoToEntity(ClientConfigDto source, ClientConfig target) {
47      if (source == null)
48        return null;
49      if (target == null)
50        target = new ClientConfig();
51
52      target.ClientConfigId = source.Id;
53      target.HeartBeatIntervall = source.HeartBeatIntervall;
54     
55      return target;
56    }
57
58    public override ClientConfigDto EntityToDto(ClientConfig source, ClientConfigDto target) {
59      if (source == null)
60        return null;
61      if (target == null)
62        target = new ClientConfigDto();
63
64      target.Id = source.ClientConfigId;
65      target.HeartBeatIntervall = source.HeartBeatIntervall;
66
67      return target;
68
69    }
70  }
71}
Note: See TracBrowser for help on using the repository browser.