Bltoolkit Комплексный Маппинг.

  • Автор темы MRadetsky
  • Дата начала
M

MRadetsky

Гость
#1
Привет всем!
Помогите понять почему не работает комплексный маппинг. Содрал пример тут http://bltoolkit.net/doc/Data/ExecuteResultSet.htm.
После выкидывания всего лишнего он имеет вид(еще в запросах дописал "FROM dual" так как ругалось на него):
<!--shcode--><pre><code class='c#'>using System;
using System.Collections.Generic;

using NUnit.Framework;

using BLToolkit.Mapping;
using BLToolkit.Data;
using BLToolkit.DataAccess;
using BLToolkit.Reflection.Extension;
using Kzo.DAL;

namespace HowTo.Data
{
[TestFixture]

public class ComplexMapping
{
const string TestQuery = @"
-- Parent Data
SELECT 1 as ParentID FROM dual
UNION SELECT 2 as ParentID FROM dual

-- Child Data
SELECT 4 ChildID, 1 as ParentID FROM dual
UNION SELECT 5 ChildID, 2 as ParentID FROM dual
UNION SELECT 6 ChildID, 2 as ParentID FROM dual
UNION SELECT 7 ChildID, 1 as ParentID FROM dual



-- Grandchild Data
SELECT 1 GrandchildID, 4 as ChildID FROM dual
UNION SELECT 2 GrandchildID, 4 as ChildID FROM dual
UNION SELECT 3 GrandchildID, 5 as ChildID FROM dual
UNION SELECT 4 GrandchildID, 5 as ChildID FROM dual
UNION SELECT 5 GrandchildID, 6 as ChildID FROM dual
UNION SELECT 6 GrandchildID, 6 as ChildID FROM dual
UNION SELECT 7 GrandchildID, 7 as ChildID FROM dual
UNION SELECT 8 GrandchildID, 7 as ChildID FROM dual
";

public class Parent
{
[MapField("ParentID")]
public int ID;

//[Relation(typeof(Child))]
public List<Child> Children = new List<Child>();
}

[MapField("ParentID", "Parent.ID")]
public class Child
{
[MapField("ChildID")]
public int ID;

//[Relation]
public Parent Parent = new Parent();

//[Relation(typeof(Grandchild))]
public List<Grandchild> Grandchildren = new List<Grandchild>();
}

[MapField("ChildID", "Child.ID")]
public class Grandchild
{
[MapField("GrandchildID")]
public int ID;

//[Relation]
public Child Child = new Child();
}

[Test]
public void Test()
{
List<Parent> parents = new List<Parent>();
MapResultSet[] 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 DbKZOManager())
{
db
.SetCommand (TestQuery)
.ExecuteResultSet(sets);
}
}
}
}[/CODE]
Если убираю связанные объекты из sets и TestQuery, то все работает нормально. А чтоб достать с связанными объектами(в таком виде как сейчас) то Ошибка "ORA-00933: SQL command not properly ended".
БД Oracle.
Подскажите что я делаю не так.