开发者

Using constructor to load data in subsonic3?

开发者 https://www.devze.com 2022-12-25 11:20 出处:网络
I\'m getting a开发者_如何学Pythonn error while trying to load an record through the constructor.

I'm getting a开发者_如何学Pythonn error while trying to load an record through the constructor.

The constructor is:

public Document(Expression<Func<Document,bool>> expression);

and i try to load a single item in like this

var x = new Document(f=>f.publicationnumber=="xxx");

publicationnumber isn't a key but tried making an it an unique key and still no go..

Am i totally wrong regarding the use of the constructor? and can someone please tell me how to use that constructor?

The error i'm getting is:

Test method TestProject1.UnitTest1.ParseFileNameTwoProductSingleLanguage threw exception: System.NullReferenceException:

with the following stacktrace:

SubSonic.Query.SqlQuery.Where[T](Expression1` expression)

Load`[T]`(T item, Expression1expression)

db.Document..ctor(Expression``1 expression) in C:\@Projects\DocumentsSearchAndAdmin\DocumentsSearchAndAdmin\Generated\ActiveRecord.cs: line 5613

rest removed for simplicity

Regards

Dennis


Use == instead of =, i.e.:

...(f=>f.publicationnumber == "xxx");


I've just gotten the SubSonic source, and found out that it had to with the expression parser and my lack of knowledge thereof .. my right side of the expression was actually an item in an string array - and s[PUBNO] (PUBNO is a const) and it was looking for an column named s instead of publicationnumber, i don't know if this i a bug or not in the linq classes

none the less - i've managed to get it to work by creating a local variable containing the value of s[PUBNO] and using that instead...

//dennis

0

精彩评论

暂无评论...
验证码 换一张
取 消