示例#1
0
 public int Bind(Route route, StopGroup stop)
 {
     lock (ctx)
     {
         TileEntry entry = new TileEntry {
             Route = route, Stop = stop
         };
         ctx.TileEntries.InsertOnSubmit(entry);
         ctx.SubmitChanges();
         return(entry.EntryID);
     }
 }
示例#2
0
        public override bool Equals(object obj)
        {
            TileEntry other = obj as TileEntry;

            if (other == null)
            {
                return(false);
            }
            else
            {
                return(EntryID == other.EntryID);
            }
        }
示例#3
0
 public int Get(Route route, StopGroup stop)
 {
     lock (ctx)
     {
         TileEntry entry = ctx.TileEntries.FirstOrDefault(e => e.RouteID == route.ID && e.StopID == stop.ID);
         if (entry == null)
         {
             return(-1);
         }
         else
         {
             return(entry.EntryID);
         }
     }
 }
示例#4
0
        public DyanamicDBContext(string connectionString, int currentDDBVersion, bool forbidMigration = false) //currentDDBVersion = Config.DDBVersion
            : base(connectionString)
        {
            if (!DatabaseExists())
            {
                CreateDatabase();
                DatabaseSchemaUpdater versionSchemaUpdater = this.CreateDatabaseSchemaUpdater();
                versionSchemaUpdater.DatabaseSchemaVersion = currentDDBVersion;
                versionSchemaUpdater.Execute();
            }
            else
            {
                DatabaseSchemaUpdater versionSchemaUpdater = this.CreateDatabaseSchemaUpdater();
                int version = versionSchemaUpdater.DatabaseSchemaVersion;
                if (version != currentDDBVersion)
                {
                    if (forbidMigration)
                    {
                        throw new InvalidOperationException("Database migration is forbidden!");
                    }
                    Migrates.Execute(versionSchemaUpdater, version, currentDDBVersion);
                }
            }

            try
            {
                FavoriteEntry entry = FavoriteEntries.FirstOrDefault();
            }
            catch (Exception e)
            {
                DatabaseSchemaUpdater databaseSchemaUpdater = this.CreateDatabaseSchemaUpdater();
                databaseSchemaUpdater.AddTable <FavoriteEntry>();
                databaseSchemaUpdater.Execute();
            }
            try
            {
                TileEntry entry = TileEntries.FirstOrDefault();
            }
            catch (Exception e)
            {
                DatabaseSchemaUpdater databaseSchemaUpdater = this.CreateDatabaseSchemaUpdater();
                databaseSchemaUpdater.AddTable <TileEntry>();
                databaseSchemaUpdater.Execute();
            }
            try
            {
                HistoryEntry entry = HistoryEntries.FirstOrDefault();
            }
            catch (Exception e)
            {
                DatabaseSchemaUpdater databaseSchemaUpdater = this.CreateDatabaseSchemaUpdater();
                databaseSchemaUpdater.AddTable <HistoryEntry>();
                databaseSchemaUpdater.Execute();
            }
            try
            {
                StopHistoryEntry entry = StopHistoryEntries.FirstOrDefault();
            }
            catch (Exception e)
            {
                DatabaseSchemaUpdater databaseSchemaUpdater = this.CreateDatabaseSchemaUpdater();
                databaseSchemaUpdater.AddTable <StopHistoryEntry>();
                databaseSchemaUpdater.Execute();
            }
            try
            {
                PlanningHistoryEntry entry = PlanningHistoryEntries.FirstOrDefault();
            }
            catch (Exception e)
            {
                DatabaseSchemaUpdater databaseSchemaUpdater = this.CreateDatabaseSchemaUpdater();
                databaseSchemaUpdater.AddTable <PlanningHistoryEntry>();
                databaseSchemaUpdater.Execute();
            }
            try
            {
                RecentEntry entry = RecentEntries.FirstOrDefault();
            }
            catch (Exception e)
            {
                DatabaseSchemaUpdater databaseSchemaUpdater = this.CreateDatabaseSchemaUpdater();
                databaseSchemaUpdater.AddTable <RecentEntry>();
                databaseSchemaUpdater.Execute();
            }
        }