static public List <RecordToken> GetLexicalFormToEntryIdPairs(Db4oDataSource db4oData, string writingSystemId) { IExtObjectContainer database = db4oData.Data.Ext(); List <Type> OriginalList = Db4oLexModelHelper.Singleton.DoNotActivateTypes; Db4oLexModelHelper.Singleton.DoNotActivateTypes = new List <Type>(); Db4oLexModelHelper.Singleton.DoNotActivateTypes.Add(typeof(LexEntry)); IQuery query = database.Query(); query.Constrain(typeof(LexicalFormMultiText)); IObjectSet lexicalForms = query.Execute(); List <RecordToken> result = new List <RecordToken>(); foreach (LexicalFormMultiText lexicalForm in lexicalForms) { query = database.Query(); query.Constrain(typeof(LexEntry)); query.Descend("_lexicalForm").Constrain(lexicalForm).Identity(); long[] ids = query.Execute().Ext().GetIDs(); //// If LexEntry does not cascade delete its lexicalForm then we could have a case where we //// don't have a entry associated with this lexicalForm. if (ids.Length == 0) { continue; } string displayString = lexicalForm.GetBestAlternative(writingSystemId, "*"); if (displayString == "*") { displayString = "(" + StringCatalog.Get("~Empty", "This is what shows for a word in a list when the user hasn't yet typed anything in for the word. Like if you click the 'New Word' button repeatedly.") + ")"; } result.Add(new RecordToken(displayString, new Db4oRepositoryId(ids[0]))); } Db4oLexModelHelper.Singleton.DoNotActivateTypes = OriginalList; return(result); }
static public List <KeyValuePair <string, long> > GetGlossToEntryIdPairs(Db4oDataSource db4oData, string writingSystemId) { IExtObjectContainer database = db4oData.Data.Ext(); List <Type> OriginalList = Db4oLexModelHelper.Singleton.DoNotActivateTypes; Db4oLexModelHelper.Singleton.DoNotActivateTypes = new List <Type>(); Db4oLexModelHelper.Singleton.DoNotActivateTypes.Add(typeof(LexEntry)); Db4oLexModelHelper.Singleton.DoNotActivateTypes.Add(typeof(LexSense)); IQuery query = database.Query(); query.Constrain(typeof(SenseGlossMultiText)); IObjectSet glosses = query.Execute(); List <KeyValuePair <string, long> > result = new List <KeyValuePair <string, long> >(); #if BROKEN foreach (SenseGlossMultiText gloss in glosses) { IQuery senseQuery = database.Query(); senseQuery.Constrain(typeof(LexSense)); senseQuery.Descend("_gloss").Constrain(gloss).Identity(); query = senseQuery.Descend("_parent"); long[] ids = query.Execute().Ext().GetIDs(); if (ids.Length == 0) { continue; } foreach (string s in SplitGlossAtSemicolon(gloss, writingSystemId)) { result.Add(new KeyValuePair <string, long>(s, ids[0])); } } #endif Db4oLexModelHelper.Singleton.DoNotActivateTypes = OriginalList; return(result); }
public static List <RecordToken> GetKeyToEntryIdPairs(Db4oDataSource db4oData, GetKeys getKeys) { IExtObjectContainer database = db4oData.Data.Ext(); IQuery query = database.Query(); query.Constrain(typeof(LexEntry)); IObjectSet entries = query.Execute(); List <RecordToken> result = new List <RecordToken>(); foreach (LexEntry entry in entries) { foreach (string key in getKeys(entry)) { result.Add(new RecordToken(key, new Db4oRepositoryId(database.GetID(entry)))); } } return(result); }
private List<KeyValuePair<string, long>> Initialize(Db4oRecordListManager recordManager) { Db4oDataSource db4oData = _recordManager.DataSource; IExtObjectContainer database = db4oData.Data.Ext(); List<Type> OriginalList = Db4oLexModelHelper.Singleton.DoNotActivateTypes; Db4oLexModelHelper.Singleton.DoNotActivateTypes = new List<Type>(); Db4oLexModelHelper.Singleton.DoNotActivateTypes.Add(typeof(LexEntry)); IQuery query = database.Query(); query.Constrain(typeof(LexicalFormMultiText)); IObjectSet lexicalForms = query.Execute(); List<KeyValuePair<string, long>> result = new List<KeyValuePair<string, long>>(); foreach (LexicalFormMultiText lexicalForm in lexicalForms) { query = database.Query(); query.Constrain(typeof(LexEntry)); query.Descend("_lexicalForm").Constrain(lexicalForm).Identity(); long[] ids = query.Execute().Ext().GetIDs(); //// If LexEntry does not cascade delete its lexicalForm then we could have a case where we //// don't have a entry associated with this lexicalForm. if (ids.Length == 0) { continue; } result.Add(new KeyValuePair<string, long>(lexicalForm.ToString(), ids[0])); } Db4oLexModelHelper.Singleton.DoNotActivateTypes = OriginalList; return result; }
public void DateTimeShouldNotLooseKind() { using (Db4oDataSource db1 = new Db4oDataSource("test.yap")) { Foo stored = new Foo(); stored._time = DateTime.UtcNow; Assert.AreEqual(DateTimeKind.Utc, stored._time.Kind); db1.Data.Set(stored); db1.Data.Close(); } using (Db4oDataSource db2 = new Db4oDataSource("test.yap")) { IObjectSet results = db2.Data.Get(null); Foo retrieved = (Foo) results[0]; Assert.AreEqual(DateTimeKind.Utc, retrieved._time.Kind); db2.Data.Close(); } }