Exemplo n.º 1
0
        public MapRelation(
            MapResultSet slaveResultSet,
            MapIndex slaveIndex,
            MapIndex masterIndex,
            string containerName)
        {
            if (masterIndex.Fields.Length == 0)
            {
                throw new MappingException("Master index length can not be 0.");
            }

            if (slaveIndex.Fields.Length == 0)
            {
                throw new MappingException("Slave index length can not be 0.");
            }

            if (masterIndex.Fields.Length != slaveIndex.Fields.Length)
            {
                throw new MappingException("Master and slave indexes do not match.");
            }

            if (string.IsNullOrEmpty(containerName))
            {
                throw new MappingException("Master container field name is wrong.");
            }

            _slaveResultSet = slaveResultSet;
            _masterIndex    = masterIndex;
            _slaveIndex     = slaveIndex;
            _containerName  = containerName;
        }
Exemplo n.º 2
0
        public void Test1()
        {
            List <Parent> parents = new List <Parent>();

            MapResultSet[] sets = new MapResultSet[2];

            sets[0] = new MapResultSet(typeof(Parent), parents);
            sets[1] = new MapResultSet(typeof(Child));

            sets[0].AddRelation(sets[1], "ParentID", "ParentID", "Children");
            sets[1].AddRelation(sets[0], "ParentID", "ParentID", "Parent");

            using (DbManager db = new DbManager())
            {
                db
                .SetCommand(_parentChildquery)
                .ExecuteResultSet(sets);
            }

            foreach (Parent p in parents)
            {
                Assert.That(p.IsDirty == false);

                foreach (Child c in p.Children)
                {
                    Assert.That(c.IsDirty == false);
                }
            }
        }
Exemplo n.º 3
0
        public TestObject SelectById(DbManager manager, Int64 ID, string LangID)
        {
            var objs = new List <TestObject>();
            var sets = new MapResultSet[4];

            sets[0] = new MapResultSet(typeof(TestObject), objs);
            sets[1] = new MapResultSet(typeof(ChildObject));
            sets[2] = new MapResultSet(typeof(MasterSiblingObject));
            sets[3] = new MapResultSet(typeof(LinkObject));

            manager
            .SetSpCommand("spTestObject_SelectDetail"
                          , manager.Parameter("@ID", ID)
                          , manager.Parameter("@LangID", LangID)
                          )
            .ExecuteResultSet(sets);

            TestObject to = objs[0];

            var lo1acc = CreateInstance <Lookup1ObjectAccessor>();
            List <Lookup1Object> lo1list = lo1acc.SelectList(manager, "en");

            to.Lookup1Object = lo1list
                               .Where(c => c.Lookup1ID == to.LookupField1)
                               .Single();

            var lo2acc = CreateInstance <Lookup2ObjectAccessor>();
            List <Lookup2Object> lo2list = lo2acc.SelectList(manager, "en");

            to.Lookup2Object = lo2list
                               .Where(c => c.Lookup2ID == to.LookupField2 && c.Lookup2ParentID == to.Lookup1Object.Lookup1ID)
                               .Single();

            return(to);
        }
Exemplo n.º 4
0
        public void ShouldMapRelationForChild()
        {
            // given
            List <Parent2Child> parents = new List <Parent2Child>();

            MapResultSet[] sets = new MapResultSet[2];

            sets[0] = new MapResultSet(typeof(Parent2Child), parents);
            sets[1] = new MapResultSet(typeof(Child2));

            // db config
            var conn = new MockDb()
                       .NewReader("ParentID")
                       .NewRow(1)
                       .NewRow(2)
                       .NextResult("ChildID", "ParentID")
                       .NewRow(4, 1)
                       .NewRow(5, 2)
                       .NewRow(6, 2)
                       .NewRow(7, 1);

            using (conn)
                using (var db = new DbManager(conn))
                {
                    // fluent config
                    new FluentMap <Parent2>()
                    .MapField(_ => _.ID, "ParentID").PrimaryKey()
                    .MapField(_ => _.Children).Relation()
                    .MapTo(db);
                    new FluentMap <Child2>()
                    .MapField(_ => _.Parent.ID, "ParentID")
                    .MapField(_ => _.ID, "ChildID").PrimaryKey()
                    .MapField(_ => _.Parent).Relation()
                    .MapTo(db);

                    // when
                    db.SetCommand("select *").ExecuteResultSet(sets);
                }

            // then
            Assert.IsTrue(parents.Any());

            foreach (Parent2Child parent in parents)
            {
                Assert.IsNotNull(parent);
                Assert.IsTrue(parent.Children.Any());

                foreach (Child2 child in parent.Children)
                {
                    Assert.AreEqual(parent, child.Parent);
                }
            }
        }
Exemplo n.º 5
0
            protected virtual LinkObject _SelectByKeyInternal(DbManagerProxy manager
                                                              , Int64?ID
                                                              , on_action loading, on_action loaded
                                                              )
            {
                MapResultSet[]    sets = new MapResultSet[1];
                List <LinkObject> objs = new List <LinkObject>();

                sets[0] = new MapResultSet(typeof(LinkObject), objs);
                LinkObject obj = null;

                try
                {
                    manager
                    .SetSpCommand("spLinkObject_SelectDetail"
                                  , manager.Parameter("@ID", ID)
                                  , manager.Parameter("@LangID", ModelUserContext.CurrentLanguage)

                                  )
                    .ExecuteResultSet(sets);

                    if (objs.Count == 0)
                    {
                        return(null);
                    }

                    obj      = objs[0];
                    obj.m_CS = m_CS;


                    if (loading != null)
                    {
                        loading(obj);
                    }
                    _SetupLoad(manager, obj);


                    //obj._setParent();
                    if (loaded != null)
                    {
                        loaded(obj);
                    }
                    obj.Loaded(manager);
                    return(obj);
                }
                catch (DataException e)
                {
                    throw DbModelException.Create(obj, e);
                }
            }
Exemplo n.º 6
0
            protected virtual VetAggregateActionDetailed _SelectByKeyInternal(DbManagerProxy manager
                                                                              , Int64?idfAggrCase
                                                                              , on_action loading, on_action loaded
                                                                              )
            {
                MapResultSet[] sets = new MapResultSet[1];
                List <VetAggregateActionDetailed> objs = new List <VetAggregateActionDetailed>();

                sets[0] = new MapResultSet(typeof(VetAggregateActionDetailed), objs);
                VetAggregateActionDetailed obj = null;

                try
                {
                    manager
                    .SetSpCommand("spVetAggregateActionDetailed_SelectDetail"
                                  , manager.Parameter("@idfAggrCase", idfAggrCase)
                                  )
                    .ExecuteResultSet(sets);

                    if (objs.Count == 0)
                    {
                        return(null);
                    }

                    obj      = objs[0];
                    obj.m_CS = m_CS;


                    if (loading != null)
                    {
                        loading(obj);
                    }
                    _SetupLoad(manager, obj);


                    //obj._setParent();
                    if (loaded != null)
                    {
                        loaded(obj);
                    }
                    obj.Loaded(manager);
                    return(obj);
                }
                catch (DataException e)
                {
                    throw DbModelException.Create(obj, e);
                }
            }
Exemplo n.º 7
0
            public virtual List <TestDiagnosisLookup> _SelectListInternal(DbManagerProxy manager
                                                                          , Int64?idfMaterial
                                                                          , Int64?idfCase
                                                                          , Int64?idfCaseType
                                                                          , on_action loading, on_action loaded
                                                                          )
            {
                TestDiagnosisLookup _obj = null;

                try
                {
                    MapResultSet[]             sets = new MapResultSet[1];
                    List <TestDiagnosisLookup> objs = new List <TestDiagnosisLookup>();
                    sets[0] = new MapResultSet(typeof(TestDiagnosisLookup), objs);

                    manager
                    .SetSpCommand("spLabTestEditable_GetSampleDiagnosis"
                                  , manager.Parameter("@idfMaterial", idfMaterial)
                                  , manager.Parameter("@idfCase", idfCase)
                                  , manager.Parameter("@idfCaseType", idfCaseType)
                                  , manager.Parameter("@LangID", ModelUserContext.CurrentLanguage)

                                  )
                    .ExecuteResultSet(sets);
                    foreach (var obj in objs)
                    {
                        _obj     = obj;
                        obj.m_CS = m_CS;

                        if (loading != null)
                        {
                            loading(obj);
                        }
                        _SetupLoad(manager, obj);

                        if (loaded != null)
                        {
                            loaded(obj);
                        }
                    }

                    return(objs);
                }
                catch (DataException e)
                {
                    throw DbModelException.Create(_obj, e);
                }
            }
Exemplo n.º 8
0
            protected virtual DataArchiveSettings _SelectByKeyInternal(DbManagerProxy manager
                                                                       , on_action loading, on_action loaded
                                                                       )
            {
                MapResultSet[]             sets = new MapResultSet[1];
                List <DataArchiveSettings> objs = new List <DataArchiveSettings>();

                sets[0] = new MapResultSet(typeof(DataArchiveSettings), objs);
                DataArchiveSettings obj = null;

                try
                {
                    manager
                    .SetSpCommand("spDataArchiveSettings_SelectDetail"
                                  )
                    .ExecuteResultSet(sets);

                    if (objs.Count == 0)
                    {
                        return(null);
                    }

                    obj      = objs[0];
                    obj.m_CS = m_CS;


                    if (loading != null)
                    {
                        loading(obj);
                    }
                    _SetupLoad(manager, obj);


                    //obj._setParent();
                    if (loaded != null)
                    {
                        loaded(obj);
                    }
                    obj.Loaded(manager);
                    return(obj);
                }
                catch (DataException e)
                {
                    throw DbModelException.Create(obj, e);
                }
            }
Exemplo n.º 9
0
            public virtual List <RegionForAzReportLookup> _SelectListInternal(DbManagerProxy manager
                                                                              , Int64?CountryID
                                                                              , Int64?ID
                                                                              , on_action loading, on_action loaded
                                                                              )
            {
                RegionForAzReportLookup _obj = null;

                try
                {
                    MapResultSet[] sets = new MapResultSet[1];
                    List <RegionForAzReportLookup> objs = new List <RegionForAzReportLookup>();
                    sets[0] = new MapResultSet(typeof(RegionForAzReportLookup), objs);

                    manager
                    .SetSpCommand("spRegionAz_SelectLookup"
                                  , manager.Parameter("@CountryID", CountryID)
                                  , manager.Parameter("@ID", ID)
                                  , manager.Parameter("@LangID", ModelUserContext.CurrentLanguage)

                                  )
                    .ExecuteResultSet(sets);
                    foreach (var obj in objs)
                    {
                        _obj     = obj;
                        obj.m_CS = m_CS;

                        if (loading != null)
                        {
                            loading(obj);
                        }
                        _SetupLoad(manager, obj);

                        if (loaded != null)
                        {
                            loaded(obj);
                        }
                    }

                    return(objs);
                }
                catch (DataException e)
                {
                    throw DbModelException.Create(_obj, e);
                }
            }
Exemplo n.º 10
0
            public virtual List <AnimalAgeLookup> _SelectListInternal(DbManagerProxy manager
                                                                      , String idfsSpecies
                                                                      , on_action loading, on_action loaded
                                                                      )
            {
                AnimalAgeLookup _obj = null;

                try
                {
                    MapResultSet[]         sets = new MapResultSet[1];
                    List <AnimalAgeLookup> objs = new List <AnimalAgeLookup>();
                    sets[0] = new MapResultSet(typeof(AnimalAgeLookup), objs);

                    manager
                    .SetSpCommand("spAnimalAgeList_SelectLookup"
                                  , manager.Parameter("@idfsSpecies", idfsSpecies)
                                  , manager.Parameter("@LangID", ModelUserContext.CurrentLanguage)

                                  )
                    .ExecuteResultSet(sets);
                    foreach (var obj in objs)
                    {
                        _obj     = obj;
                        obj.m_CS = m_CS;

                        if (loading != null)
                        {
                            loading(obj);
                        }
                        _SetupLoad(manager, obj);

                        if (loaded != null)
                        {
                            loaded(obj);
                        }
                    }

                    return(objs);
                }
                catch (DataException e)
                {
                    throw DbModelException.Create(_obj, e);
                }
            }
Exemplo n.º 11
0
            public virtual List <Lookup2ParamTable> _SelectListInternal(DbManagerProxy manager
                                                                        , Int32?ParentID
                                                                        , on_action loading, on_action loaded
                                                                        )
            {
                Lookup2ParamTable _obj = null;

                try
                {
                    MapResultSet[]           sets = new MapResultSet[1];
                    List <Lookup2ParamTable> objs = new List <Lookup2ParamTable>();
                    sets[0] = new MapResultSet(typeof(Lookup2ParamTable), objs);

                    manager
                    .SetSpCommand("spLookupTable2Param_SelectLookup"
                                  , manager.Parameter("@ParentID", ParentID)
                                  , manager.Parameter("@LangID", ModelUserContext.CurrentLanguage)

                                  )
                    .ExecuteResultSet(sets);
                    foreach (var obj in objs)
                    {
                        _obj     = obj;
                        obj.m_CS = m_CS;

                        if (loading != null)
                        {
                            loading(obj);
                        }
                        _SetupLoad(manager, obj);

                        if (loaded != null)
                        {
                            loaded(obj);
                        }
                    }

                    return(objs);
                }
                catch (DataException e)
                {
                    throw DbModelException.Create(_obj, e);
                }
            }
Exemplo n.º 12
0
            public virtual List <SmphBaseReferenceTranslationLookup> _SelectListInternal(DbManagerProxy manager
                                                                                         , Int64?idfsReferenceType
                                                                                         , String lang
                                                                                         , on_action loading, on_action loaded
                                                                                         )
            {
                SmphBaseReferenceTranslationLookup _obj = null;

                try
                {
                    MapResultSet[] sets = new MapResultSet[1];
                    List <SmphBaseReferenceTranslationLookup> objs = new List <SmphBaseReferenceTranslationLookup>();
                    sets[0] = new MapResultSet(typeof(SmphBaseReferenceTranslationLookup), objs);

                    manager
                    .SetSpCommand("spSmphBaseReferenceTranslation_SelectLookup"
                                  , manager.Parameter("@idfsReferenceType", idfsReferenceType)
                                  , manager.Parameter("@lang", lang)
                                  )
                    .ExecuteResultSet(sets);
                    foreach (var obj in objs)
                    {
                        _obj     = obj;
                        obj.m_CS = m_CS;

                        if (loading != null)
                        {
                            loading(obj);
                        }
                        _SetupLoad(manager, obj);

                        if (loaded != null)
                        {
                            loaded(obj);
                        }
                    }

                    return(objs);
                }
                catch (DataException e)
                {
                    throw DbModelException.Create(_obj, e);
                }
            }
Exemplo n.º 13
0
            public virtual List <HACodeLookup> _SelectListInternal(DbManagerProxy manager
                                                                   , Int32?intHACodeMask
                                                                   , on_action loading, on_action loaded
                                                                   )
            {
                HACodeLookup _obj = null;

                try
                {
                    MapResultSet[]      sets = new MapResultSet[1];
                    List <HACodeLookup> objs = new List <HACodeLookup>();
                    sets[0] = new MapResultSet(typeof(HACodeLookup), objs);

                    manager
                    .SetSpCommand("spHACode_SelectCheckList"
                                  , manager.Parameter("@intHACodeMask", intHACodeMask)
                                  , manager.Parameter("@LangID", ModelUserContext.CurrentLanguage)

                                  )
                    .ExecuteResultSet(sets);
                    foreach (var obj in objs)
                    {
                        _obj     = obj;
                        obj.m_CS = m_CS;

                        if (loading != null)
                        {
                            loading(obj);
                        }
                        _SetupLoad(manager, obj);

                        if (loaded != null)
                        {
                            loaded(obj);
                        }
                    }

                    return(objs);
                }
                catch (DataException e)
                {
                    throw DbModelException.Create(_obj, e);
                }
            }
Exemplo n.º 14
0
        public void Test()
        {
            List <Parent> parents = new List <Parent>();

            /*[a]*/ MapResultSet /*[/a]*/[] sets = new MapResultSet[3];

            sets[0] = new MapResultSet(typeof(Parent), parents);
            sets[1] = new MapResultSet(typeof(Child));
            sets[2] = new MapResultSet(typeof(Grandchild));

            sets[0].AddRelation(sets[1], "ParentID", "ParentID", "Children");
            sets[1].AddRelation(sets[0], "ParentID", "ParentID", "Parent");

            sets[1].AddRelation(sets[2], "ChildID", "ChildID", "Grandchildren");
            sets[2].AddRelation(sets[1], "ChildID", "ChildID", "Child");

            using (DbManager db = new DbManager())
            {
                db
                .SetCommand(TestQuery)
                ./*[a]*/ ExecuteResultSet/*[/a]*/ (sets);
            }

            Assert.IsNotEmpty(parents);

            foreach (Parent parent in parents)
            {
                Assert.IsNotNull(parent);
                Assert.IsNotEmpty(parent.Children);

                foreach (Child child in parent.Children)
                {
                    Assert.AreEqual(parent, child.Parent);
                    Assert.IsNotEmpty(child.Grandchildren);

                    foreach (Grandchild grandchild in child.Grandchildren)
                    {
                        Assert.AreEqual(child, grandchild.Child);
                        Assert.AreEqual(parent, grandchild.Child.Parent);
                    }
                }
            }
        }
Exemplo n.º 15
0
            public virtual List <SmphInvisibleFieldsLookup> _SelectListInternal(DbManagerProxy manager
                                                                                , Int64?idfCustomizationPackage
                                                                                , on_action loading, on_action loaded
                                                                                )
            {
                SmphInvisibleFieldsLookup _obj = null;

                try
                {
                    MapResultSet[] sets = new MapResultSet[1];
                    List <SmphInvisibleFieldsLookup> objs = new List <SmphInvisibleFieldsLookup>();
                    sets[0] = new MapResultSet(typeof(SmphInvisibleFieldsLookup), objs);

                    manager
                    .SetSpCommand("spSmphInvisibleFields_SelectLookup"
                                  , manager.Parameter("@idfCustomizationPackage", idfCustomizationPackage)
                                  )
                    .ExecuteResultSet(sets);
                    foreach (var obj in objs)
                    {
                        _obj     = obj;
                        obj.m_CS = m_CS;

                        if (loading != null)
                        {
                            loading(obj);
                        }
                        _SetupLoad(manager, obj);

                        if (loaded != null)
                        {
                            loaded(obj);
                        }
                    }

                    return(objs);
                }
                catch (DataException e)
                {
                    throw DbModelException.Create(_obj, e);
                }
            }
Exemplo n.º 16
0
            public virtual List <RuleConstant> _SelectListInternal(DbManagerProxy manager
                                                                   , Int64?idfsRule
                                                                   , on_action loading, on_action loaded
                                                                   )
            {
                RuleConstant _obj = null;

                try
                {
                    MapResultSet[]      sets = new MapResultSet[1];
                    List <RuleConstant> objs = new List <RuleConstant>();
                    sets[0] = new MapResultSet(typeof(RuleConstant), objs);

                    manager
                    .SetSpCommand("spFFGetRuleConstant"
                                  , manager.Parameter("@idfsRule", idfsRule)
                                  )
                    .ExecuteResultSet(sets);
                    foreach (var obj in objs)
                    {
                        _obj     = obj;
                        obj.m_CS = m_CS;

                        if (loading != null)
                        {
                            loading(obj);
                        }
                        _SetupLoad(manager, obj);

                        if (loaded != null)
                        {
                            loaded(obj);
                        }
                    }

                    return(objs);
                }
                catch (DataException e)
                {
                    throw DbModelException.Create(_obj, e);
                }
            }
Exemplo n.º 17
0
            public virtual List <Observation> _SelectListInternal(DbManagerProxy manager
                                                                  , String observationList
                                                                  , on_action loading, on_action loaded
                                                                  )
            {
                Observation _obj = null;

                try
                {
                    MapResultSet[]     sets = new MapResultSet[1];
                    List <Observation> objs = new List <Observation>();
                    sets[0] = new MapResultSet(typeof(Observation), objs);

                    manager
                    .SetSpCommand("spFFGetObservations"
                                  , manager.Parameter("@observationList", observationList)
                                  )
                    .ExecuteResultSet(sets);
                    foreach (var obj in objs)
                    {
                        _obj     = obj;
                        obj.m_CS = m_CS;

                        if (loading != null)
                        {
                            loading(obj);
                        }
                        _SetupLoad(manager, obj);

                        if (loaded != null)
                        {
                            loaded(obj);
                        }
                    }

                    return(objs);
                }
                catch (DataException e)
                {
                    throw DbModelException.Create(_obj, e);
                }
            }
Exemplo n.º 18
0
            public virtual List <PostalCodeLookup> _SelectListInternal(DbManagerProxy manager
                                                                       , Int64?SettlementID
                                                                       , on_action loading, on_action loaded
                                                                       )
            {
                PostalCodeLookup _obj = null;

                try
                {
                    MapResultSet[]          sets = new MapResultSet[1];
                    List <PostalCodeLookup> objs = new List <PostalCodeLookup>();
                    sets[0] = new MapResultSet(typeof(PostalCodeLookup), objs);

                    manager
                    .SetSpCommand("spPostalCode_SelectLookup"
                                  , manager.Parameter("@SettlementID", SettlementID)
                                  )
                    .ExecuteResultSet(sets);
                    foreach (var obj in objs)
                    {
                        _obj     = obj;
                        obj.m_CS = m_CS;

                        if (loading != null)
                        {
                            loading(obj);
                        }
                        _SetupLoad(manager, obj);

                        if (loaded != null)
                        {
                            loaded(obj);
                        }
                    }

                    return(objs);
                }
                catch (DataException e)
                {
                    throw DbModelException.Create(_obj, e);
                }
            }
Exemplo n.º 19
0
        public void TestFailResultSet2()
        {
            MapResultSet[] sets = new MapResultSet[2];

            sets[0] = new MapResultSet(typeof(Master));
            sets[1] = new MapResultSet(typeof(Slave));

            sets[0].AddRelation(sets[1], "Master", "MasterID", "Slaves");

            using (DbManager db = new DbManager())
            {
                db
#if ORACLE
                .SetSpCommand("ResultSetTest")
#else
                .SetCommand(SqlResultSet)
#endif
                .ExecuteResultSet(sets);
            }
        }
Exemplo n.º 20
0
 public virtual List<FFTemplateLookup> _SelectListInternal(DbManagerProxy manager
     , Int64? idfsFormTemplate
     , Int64? idfsFormType
     , on_action loading, on_action loaded
     )
 {
     FFTemplateLookup _obj = null;
     try
     {
         MapResultSet[] sets = new MapResultSet[1];
         List<FFTemplateLookup> objs = new List<FFTemplateLookup>();
         sets[0] = new MapResultSet(typeof(FFTemplateLookup), objs);
         
         manager
             .SetSpCommand("spFFGetTemplates"
                 , manager.Parameter("@idfsFormTemplate", idfsFormTemplate)
                 , manager.Parameter("@idfsFormType", idfsFormType)
                 , manager.Parameter("@LangID", ModelUserContext.CurrentLanguage)
                 
                 )
             .ExecuteResultSet(sets);
         foreach(var obj in objs) 
         {
             _obj = obj;
             obj.m_CS = m_CS;
             
             if (loading != null)
                 loading(obj);
             _SetupLoad(manager, obj);
             
             if (loaded != null)
                 loaded(obj);
         }
         
         return objs;
     }
     catch(DataException e)
     {
         throw DbModelException.Create(_obj, e);
     }
 }
Exemplo n.º 21
0
            public virtual List <SmphDiagnosisLookup> _SelectListInternal(DbManagerProxy manager
                                                                          , on_action loading, on_action loaded
                                                                          )
            {
                SmphDiagnosisLookup _obj = null;

                try
                {
                    MapResultSet[]             sets = new MapResultSet[1];
                    List <SmphDiagnosisLookup> objs = new List <SmphDiagnosisLookup>();
                    sets[0] = new MapResultSet(typeof(SmphDiagnosisLookup), objs);

                    manager
                    .SetSpCommand("spSmphDiagnosis_SelectLookup"
                                  )
                    .ExecuteResultSet(sets);
                    foreach (var obj in objs)
                    {
                        _obj     = obj;
                        obj.m_CS = m_CS;

                        if (loading != null)
                        {
                            loading(obj);
                        }
                        _SetupLoad(manager, obj);

                        if (loaded != null)
                        {
                            loaded(obj);
                        }
                    }

                    return(objs);
                }
                catch (DataException e)
                {
                    throw DbModelException.Create(_obj, e);
                }
            }
Exemplo n.º 22
0
        public void TestResultSet()
        {
            MapResultSet[] sets = new MapResultSet[2];

            sets[0] = new MapResultSet(typeof(Master));
            sets[1] = new MapResultSet(typeof(Slave));

            sets[0].AddRelation(sets[1], "MasterID", "MasterID", "Slaves");

            using (DbManager db = new DbManager())
            {
                db
#if ORACLE
                .SetSpCommand("ResultSetTest")
#else
                .SetCommand(SqlResultSet)
#endif
                .ExecuteResultSet(sets);
            }

            Assert.AreEqual(7, ((Slave)(((Master)sets[0].List[0]).Slaves[1])).ID);
        }
Exemplo n.º 23
0
        public void Test3()
        {
            var parents = new List <ParentEx>();
            var sets    = new /*[a]*/ MapResultSet /*[/a]*/[3];

            sets[0] = new MapResultSet(typeof(ParentEx), parents);
            sets[1] = new MapResultSet(typeof(ChildEx));
            sets[2] = new MapResultSet(typeof(GrandchildEx));

            using (var db = new DbManager())
            {
                db.MappingSchema = _mappingSchema;

                db
                .SetCommand(TestQuery)
                ./*[a]*/ ExecuteResultSet/*[/a]*/ (sets);
            }

            Assert.IsNotEmpty(parents);

            foreach (ParentEx parent in parents)
            {
                Assert.IsNotNull(parent);
                Assert.IsNotEmpty(parent.Children);

                foreach (ChildEx child in parent.Children)
                {
                    Assert.AreEqual(parent, child.Parent);
                    Assert.IsNotEmpty(child.Grandchildren);

                    foreach (GrandchildEx grandchild in child.Grandchildren)
                    {
                        Assert.AreEqual(child, grandchild.Child);
                        Assert.AreEqual(parent, grandchild.Child.Parent);
                    }
                }
            }
        }
Exemplo n.º 24
0
		public MapRelation(
			MapResultSet slaveResultSet,
			MapIndex     slaveIndex,
			MapIndex     masterIndex,
			string       containerName)
		{
			if (masterIndex.Fields.Length == 0)
				throw new MappingException("Master index length can not be 0.");

			if ( slaveIndex.Fields.Length == 0)
				throw new MappingException("Slave index length can not be 0.");

			if (masterIndex.Fields.Length != slaveIndex.Fields.Length)
				throw new MappingException("Master and slave indexes do not match.");

			if (string.IsNullOrEmpty(containerName))
				throw new MappingException("Master container field name is wrong.");

			_slaveResultSet  = slaveResultSet;
			_masterIndex     = masterIndex;
			_slaveIndex      = slaveIndex;
			_containerName   = containerName;
		}