Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.CEDMA.DB/Database.cs @ 357

Last change on this file since 357 was 357, checked in by gkronber, 16 years ago

worked on ticket #187. code is a mess. work-in-progress.

File size: 1.0 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Data.Linq;
6using HeuristicLab.CEDMA.DB.Interfaces;
7using System.ServiceModel;
8
9namespace HeuristicLab.CEDMA.DB {
10  [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple, UseSynchronizationContext = false)]
11  public class Database : DataContext, IDatabase {
12    Table<Agent> Agents;
13
14    public Database() : this("c:\\cedma.mdf") { }
15
16    public Database(string connection) : base(connection) {
17    }
18
19    public IList<IAgent> GetAgents() {
20      List<IAgent> result = new List<IAgent>();
21      foreach(Agent a in Agents) {
22        result.Add(a);
23      }
24      return result;
25    }
26
27    public IAgent CreateAgent() {
28      Agent newAgent = new Agent();
29      newAgent.Name = DateTime.Now.ToString();
30      newAgent.Status = AgentStatus.Waiting;
31      newAgent.RawData = null;
32      Agents.InsertOnSubmit(newAgent);
33      this.SubmitChanges();
34      return newAgent;
35    }
36  }
37}
Note: See TracBrowser for help on using the repository browser.