views:

36

answers:

2

I'm getting an 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, Expression
1expression)
db.Document..ctor(Expression``1
expression) in C:\@Projects\DocumentsSearchAndAdmin\DocumentsSearchAndAdmin\Generated\ActiveRecord.cs: line 5613
rest removed for simplicity

Regards
Dennis

A: 

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

...(f=>f.publicationnumber == "xxx");
Marcelo Cantos
that's a typo ..
Dennis
A: 

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

Dennis