コード例 #1
0
        public void TestQuerying(Type dataType)
        {
            RunAsync(async delegate {
                var mgr = new ForeignRelationManager();

                // Test null relation
                var relation = new ForeignRelation()
                {
                    Type = dataType,
                    Id   = null,
                };
                Assert.IsNull(await mgr.QueryAsync(relation));

                // Test missing relation
                relation = new ForeignRelation()
                {
                    Type = dataType,
                    Id   = Guid.NewGuid(),
                };
                Assert.IsNull(await mgr.QueryAsync(relation));

                // Create dummy data:
                var inst = (CommonData)Activator.CreateInstance(dataType);
                inst.Id  = relation.Id.Value;

                var putAsyncMethod = DataStore.GetType().GetMethod("PutAsync").MakeGenericMethod(dataType);
                await(Task) putAsyncMethod.Invoke(DataStore, new object[] { inst });
                Assert.IsNotNull(await mgr.QueryAsync(relation));
            });
        }
コード例 #2
0
        private bool AssignForeignSectionId(Row targetRow, ForeignRelation foreignRelation)
        {
            if ((foreignRelation.ForeignTable == null) ||
                (targetRow.Fields[foreignRelation.LocalKeyIndex] == null) ||
                (targetRow.Fields[foreignRelation.LocalKeyIndex].Data == null))
            {
                return(false);
            }

            foreach (Row foreignRow in foreignRelation.ForeignTable.Rows)
            {
                if (!string.IsNullOrEmpty(foreignRow.SectionId) &&
                    (foreignRow.Fields[foreignRelation.ForeignKeyIndex] != null) &&
                    targetRow.Fields[foreignRelation.LocalKeyIndex].Data.Equals(foreignRow.Fields[foreignRelation.ForeignKeyIndex].Data))
                {
                    targetRow.SectionId = foreignRow.SectionId;
                    return(true);
                }
            }
            return(false);
        }