public LibraryQueryHelper (TypedTable <Record, string> table, Library library) { this.Table = table; this.Library = library; this.UpdatedSubject = new Subject <DatabaseUpdatedEventArgs>().AddTo(this.Disposables); }
static Person FindPerson(TypedTable <Person> masterDirectory, DataTable ykData, PersonData ykPerson, int ykid) { var mdRow = masterDirectory.Rows.FirstOrDefault(p => p.YKID == ykid); if (mdRow != null && mdRow.LastName != ykPerson.LastName) { var candidates = masterDirectory.Rows .Where(md => md.LastName == ykPerson.LastName && md.YKID != null && ykData.Select("IDNUM=" + md.YKID).Length == 0 ).ToArray(); if (candidates.Length == 1) { mdRow = candidates[0]; } else if (candidates.Length > 1) { candidates = candidates.Where(md => md.Phone == ykPerson.Phone).ToArray(); if (candidates.Length == 1) { mdRow = candidates[0]; } } } return(mdRow); }
public Sample() { var dbPath = @"test.db"; this.database = new DatabaseFront(dbPath); this.table1 = new TypedTable <Record, string>(this.database, "table1") { IsIdAuto = false, Version = 2, }; //table1.AddColumnOption(nameof(Table1.NewNumber), "DEFAULT 3"); //table1.AddColumnOption(nameof(Table1.NewText), "DEFAULT 'あおえ'"); //table1.AddColumnOption(nameof(Table1.IsEnabled), "DEFAULT 1"); // //table1.Migrating += (o, e) => //{ // if (e.TableInformations.First(x => x.TableName.Equals(this.table1.Name)) // .Modified < new DateTime(2016, 1, 1)) // { // e.Converters[nameof(Table1.NewNumber)] = "(SubNumber*2)+5"; // } //}; }
public static void ResultsAreEqual(TypedTable expectedRows, IEnumerable <IDictionary <string, object> > actualRows, bool strictOrdering = true) { var expectedResults = expectedRows.ToDictionaries().ToList(); expectedResults.Sort(DictionariesComparator.CompareTo); var actualResults = actualRows.Select(dic => dic .Where(d => expectedRows.Header.Contains(d.Key)) .ToDictionary(d => d.Key, d => d.Value)) .ToList(); actualResults.Sort(DictionariesComparator.CompareTo); if (strictOrdering) { actualResults.Should().BeEquivalentTo(expectedResults, options => options .WithStrictOrdering() .Using <object>(CustomDateComparison) .When(info => CustomDateComparisonRequired(info, expectedRows)) ); } else { actualResults.Should().BeEquivalentTo(expectedResults, options => options .Using <object>(CustomDateComparison) .When(info => CustomDateComparisonRequired(info, expectedRows)) ); } }
public TypedTable <T> GetTable <T>(string tableName) { var connstr = ConnectionString.Build(ConnectionString).WithTable(tableName); var tbl = new TypedTable <T>(connstr); return(tbl); }
internal static Person AddPerson(this TypedTable <Person> table, PersonData data, string source) { var retVal = new Person { Source = source }; retVal.Set(data); table.Rows.Add(retVal); return(retVal); }
public void Execute(IServices parameter) { var table = new TypedTable <ISerializerComposer>(); foreach (var result in _store) { table.Assign(result.Key, result.Value.Get(parameter)); } _assign.Execute(table); }
public static bool CustomDateComparisonRequired(IMemberInfo info, TypedTable expectedRows) { var selectedMemberPathNameRegex = new Regex(@"\[\d+\]\[(.+)\]"); if (!selectedMemberPathNameRegex.IsMatch(info.SelectedMemberPath)) { return(false); } var columnName = selectedMemberPathNameRegex.Match(info.SelectedMemberPath).Groups[1].Value; return(expectedRows.ColumnTypes[columnName] == typeof(CustomDateComparison)); }
public Grouping (TypedTable <Record, string> table, Library library) { this.Table = table; this.Library = library; this.recordSql = $"SELECT DISTINCT {nameof(Record.GroupKey)} FROM {this.Table.Name}" + $" WHERE ({nameof(Record.IsGroup)} == 0 AND {nameof(Record.Id)} IN @{nameof(Tuple<string[]>.Item1)})"; this.groupSql = $"SELECT DISTINCT {nameof(Record.Id)} FROM {this.Table.Name}" + $" WHERE ({nameof(Record.IsGroup)} > 0 AND {nameof(Record.Id)} IN @{nameof(Tuple<string[]>.Item1)})"; }
public Sample2() { var dbPath = @"test2.db"; this.database = new DatabaseFront(dbPath); this.table1 = new TypedTable <Table1, string>(this.database, "table1") { IsIdAuto = false, Version = 2, }; }
///<summary>Creates a SimplePersonDetails form that displays the specified person.</summary> public SimplePersonDetails(Person person) { InitializeComponent(); this.person = person; table = person.Table; if (table != null) { table.ValueChanged += table_ValueChanged; table.RowRemoved += table_RowRemoved; } editor.Person = person; UpdateDetails(); }
private async Task ConvertFileDatabase (Library library, TypedTable <Record, string> records, Action <int> OnLoaded, Action <int> OnAdding) { this.ConvertFiles(); ConvertGroups(library); OnLoaded?.Invoke(this.Files.Count); var count = 0; foreach (var items in this.Files.Select(x => x.Value).Buffer(1024)) { await records.ReplaceRangeBufferedAsync(items); count += items.Count; OnAdding?.Invoke(count); } //await records.ReplaceRangeBufferedAsync(this.Files.Select(x => x.Value)); //return this.Files.Select(x => x.Value); }
public async Task Start2(LibrarySettings libSettings, Library library, TypedTable <Record, string> records, Action <int> OnLoaded, Action <int> OnAdding) { this.ConvertLibrarySettings(libSettings); library.InitializeLibrarySettings(libSettings); this.ConvertLibraryData(library); var ignored = new HashSet <TagInformation>(); var tagMax = this.Tags.Max(x => x.Key); for (int i = 1; i <= tagMax; i++) { TagInformation tag; if (!this.Tags.TryGetValue(i, out tag)) { tag = new TagInformation() { IsIgnored = false, Name = i.ToString(), }; ignored.Add(tag); } var newKey = library.Tags.SetTag(tag); } //this.Tags.OrderBy(x=>x.Key).ForEach(x => library.Tags.SetTag(x.Value)); ignored.ForEach(x => x.IsIgnored = true); await Task.Delay(1000); await this.ConvertFileDatabase(library, records, OnLoaded, OnAdding); }
public GroupQuery(TypedTable <Record, string> table, Library library) { this.Table = table; this.Library = library; }
public override void XmlLoad(XmlNode node) { var relationshipsNode = node.SelectSingleNode("relationships"); //deprecated, use "r" if (relationshipsNode == null) { relationshipsNode = node.SelectSingleNode("r"); } if (relationshipsNode != null) { this.Relationships.XmlLoad(relationshipsNode); } var columnsNode = node.SelectSingleNode("columns"); //deprecated, use "c" if (columnsNode == null) { columnsNode = node.SelectSingleNode("c"); } if (columnsNode != null) { this.Columns.XmlLoad(columnsNode); } var tableIndexListNode = node.SelectSingleNode("til"); if (tableIndexListNode != null) { TableIndexList.XmlLoad(tableIndexListNode, this.Root); } this.Immutable = XmlHelper.GetAttributeValue(node, "immutable", _def_immutable); this.IsTenant = XmlHelper.GetAttributeValue(node, "isTenant", _def_isTenant); this.ResetId(XmlHelper.GetAttributeValue(node, "id", this.Id)); var staticDataNode = node.SelectSingleNode("staticData"); if (staticDataNode != null) { this.StaticData.XmlLoad(staticDataNode); } this.AssociativeTable = XmlHelper.GetAttributeValue(node, "associativeTable", AssociativeTable); this.HasHistory = XmlHelper.GetAttributeValue(node, "hasHistory", HasHistory); this.FullIndexSearch = XmlHelper.GetAttributeValue(node, "fullIndexSearch", _def_fullIndexSearch); this.Key = XmlHelper.GetAttributeValue(node, "key", string.Empty); this.Name = XmlHelper.GetAttributeValue(node, "name", string.Empty); this.DBSchema = XmlHelper.GetAttributeValue(node, "dbschema", _def_dbSchema); this.CodeFacade = XmlHelper.GetAttributeValue(node, "codeFacade", _def_codeFacade); this.Description = XmlHelper.GetAttributeValue(node, "description", _def_description); this.AllowModifiedAudit = XmlHelper.GetAttributeValue(node, "modifiedAudit", AllowModifiedAudit); this.AllowCreateAudit = XmlHelper.GetAttributeValue(node, "createAudit", _def_createAudit); this.TypedTable = (TypedTableConstants)XmlHelper.GetAttributeValue(node, "typedTable", int.Parse(TypedTable.ToString("d"))); this.AllowTimestamp = XmlHelper.GetAttributeValue(node, "timestamp", AllowTimestamp); this.GeneratesDoubleDerived = XmlHelper.GetAttributeValue(node, "generatesDoubleDerived", _def_generatesDoubleDerived); }
public override XmlNode XmlLoad(XmlNode node) { this.Immutable = node.GetAttributeValue("immutable", _def_immutable); this.IsTenant = node.GetAttributeValue("isTenant", _def_isTenant); this.ResetId(XmlHelper.GetAttributeValue(node, "id", this.Id)); this.AssociativeTable = node.GetAttributeValue("associativeTable", AssociativeTable); this.HasHistory = node.GetAttributeValue("hasHistory", HasHistory); this.FullIndexSearch = node.GetAttributeValue("fullIndexSearch", _def_fullIndexSearch); this.Key = node.GetAttributeValue("key", string.Empty); this.Name = node.GetAttributeValue("name", string.Empty); this.DBSchema = node.GetAttributeValue("dbschema", _def_dbSchema); this.CodeFacade = node.GetAttributeValue("codeFacade", _def_codeFacade); this.Description = node.GetAttributeValue("description", _def_description); this.AllowModifiedAudit = node.GetAttributeValue("modifiedAudit", AllowModifiedAudit); this.AllowCreateAudit = node.GetAttributeValue("createAudit", _def_createAudit); this.TypedTable = (TypedTableConstants)XmlHelper.GetAttributeValue(node, "typedTable", int.Parse(TypedTable.ToString("d"))); this.AllowConcurrencyCheck = node.GetAttributeValue("timestamp", AllowConcurrencyCheck); this.GeneratesDoubleDerived = node.GetAttributeValue("generatesDoubleDerived", _def_generatesDoubleDerived); this.Relationships.XmlLoad(node.SelectSingleNode("r")); this.Columns.XmlLoad(node.SelectSingleNode("c")); this.TableIndexList.XmlLoad(node.SelectSingleNode("til"), this.Root); this.StaticData.XmlLoad(node.SelectSingleNode("staticData")); return(node); }
static Person FindPerson(TypedTable<Person> masterDirectory, DataTable ykData, PersonData ykPerson, int ykid) { var mdRow = masterDirectory.Rows.FirstOrDefault(p => p.YKID == ykid); if (mdRow != null && mdRow.LastName != ykPerson.LastName) { var candidates = masterDirectory.Rows .Where(md => md.LastName == ykPerson.LastName && md.YKID != null && ykData.Select("IDNUM=" + md.YKID).Length == 0 ).ToArray(); if (candidates.Length == 1) mdRow = candidates[0]; else if (candidates.Length > 1) { candidates = candidates.Where(md => md.Phone == ykPerson.Phone).ToArray(); if (candidates.Length == 1) mdRow = candidates[0]; } } return mdRow; }
public async Task GivenTheTableOnTheDatabaseOnlyContainsTheData(string tableName, string databaseName, TypedTable contents) { await Context.Database.InsertAsync(databaseName, tableName, contents); }
public async Task ThenTheTableOnTheDatabaseShouldOnlyContainTheDataNoOrdering(string tableName, string databaseName, TypedTable expectedRows) { var actualRows = await Context.Database.ReadAllAsync(databaseName, tableName); CustomAssertions.ResultsAreEqual(expectedRows, actualRows, false); }
public static TableDefinition<T> FromTable<T>(TypedTable<T> table) { return FromTable<T>((ITable)table); }
public async Task InsertAsync(string databaseName, string tableName, TypedTable table) { await InsertAsync(databaseName, tableName, table.ToDictionaries()); }