1

Base entity interface is IEntity which requires only "object ID {get;set;}" to be implemented. Now, in almost every case ID is of Guid type (except for membership etc). I am using following code to do mapping of interface

...
    AnyPart<IEntity> primaryMap = ReferencesAny(x => x.Primary)
                    .IdentityType<object>() // tried with .IdentityType<Guid>()
                    .EntityIdentifierColumn("PrimaryID")
                    .EntityTypeColumn("PrimaryType")
                    .MetaType<string>();
...

Of course, next I am adding meta values.

So, Now getting error

Source array was not long enough. Check srcIndex and length, and the array's lower bound

And with .IdentityType<Guid>()

could not resolve property: Primary.ID of: Founder.Connection [.SingleOrDefault[Founder.Connection](NHibernate.Linq.NhQueryable`1[Founder.Connection], Quote((x, ) => (OrElse(AndAlso(Equal(x.Primary.ID, 35c2142a-4c17-4b77-96fd-a2570028a211), Equal(x.Secondary.ID, 35c2142a-4c17-4b77-96fd-a2570028a211)), AndAlso(Equal(x.Secondary.ID, 35c2142a-4c17-4b77-96fd-a2570028a211), Equal(x.Primary.ID, 35c2142a-4c17-4b77-96fd-a2570028a211))))), )]

UPDATE:

I tried also with .IdentityType(x=>x.ID) but same problem (Source array was not long enough)

UPDATE II:

Query (Actually whole method containing query) that this error occurs on is bellow:

public IQueryable<Connection> GetConnections(IEntity connectable)
        {
            IQueryable<Connection> query =
                Query().Where(
                    x => x.Primary.ID == connectable.ID || x.Secondary.ID == connectable.ID);
            return query;
        }

A couple of things spring to mind:

Have you actually created the modules/Mytest directory and populated it? (Using the template in vtlib/ModuleDir/5.4.0 and then editing the filenames and class of Mytest.php)

Check the case of your module class definition, e.g. class Mytest vs. class Mytest

If you are using any version control or symlinks in the development of your modules/Mytest code then this can trigger the "Sorry! Attempt to access restricted file." messages.

In module setup script make sure you have added this lines.

$module->initTables(); 
$module->initWebservice();
4

1 に答える 1

1

クエリでこれを試してください: x.Primary == connectable(なしID)。

問題は、 (または別のマップされていない型、それがマッピングobjectが必要な理由) を参照することです。anyありませんIDobject

ちなみに、HQL を使用するとid、Linq では使用できないキーワード を使用して id にアクセスできます (技術的には、拡張メソッドとして使用できるようにすることもできますが、Linq から NH への変換が適切かどうかはわかりません)。実施されていた)。すべてanyの参照は概念的にidとを持っていclassます。

于 2013-11-14T07:42:46.910 に答える