This is a migrated thread and some comments may be shown as answers.

Error: Exception has been thrown by the target of an invocation.

3 Answers 239 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Gerrit
Top achievements
Rank 2
Gerrit asked on 21 Dec 2011, 07:04 AM
Hi,

I'm getting this error when I do the following :
var events = App.WorkWith().Events()
.Where( n => ( n.Status == ContentLifecycleStatus.Live ) && ( n.Owner == Base.BrokerInformation.BrokerId ) )
.Get()
.ToList();

The inner exception is :
line 1:152: expecting "TOK_UNSIGNED_INTEGER", found '3.' ("3." is a reserved word.)
Original Query: DEFINE EXTENT extnt FOR Telerik.Sitefinity.Events.Model.Event; SELECT * FROM extnt AS t1  WHERE t1.appName =  $1 AND (t1.status =  $2 AND t1.owner =  $3.BrokerId )

The stacktrace is :
   at Telerik.Sitefinity.Data.Linq.Oql.OqlQueryProvider`2.ExecuteKnownType[TResult](IObjectScope scope, String queryText, Boolean isEnumerable, Int32 skip, Int32 take, IList parameters, ElementOperator op)
   at Telerik.Sitefinity.Data.Linq.Oql.OqlQueryProvider`2.Execute[TResult](Expression expression)

I did check, the "Base.BrokerInformation.BrokerId" is a valid Guid.

What is wrong? How do I fix this error?

I'm Using Sitefinity 4.0.

Thanks for your help in advanced.

Kind Regards,
Gerrit

3 Answers, 1 is accepted

Sort by
0
Gerrit
Top achievements
Rank 2
answered on 21 Dec 2011, 09:00 AM
I found the problem...
You cannot use properties in the fluent API.
Not sure if this is fixed in the newer versions of Sitefinity.
0
Nikolay Datchev
Telerik team
answered on 22 Dec 2011, 12:05 PM
Hi,
I think upgrading to the most recent version of sitefinity should be the best since now LINQ queries are processed very differently and many problems like this one should have disappeared. I would suggest that in this case you can try putting the value of BrokerId into a variable and then querying by this variable rather than the class property. This will work around the missing implementation in 4.0.
var brokerid=Base.BrokerInformation.BrokerId;
var events = App.WorkWith().Events()
.Where( n => ( n.Status == ContentLifecycleStatus.Live ) && ( n.Owner == brokerid ) )
.Get()
.ToList();


All the best,
Nikolay Datchev
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Gerrit
Top achievements
Rank 2
answered on 22 Dec 2011, 12:09 PM
Hi Nikolay,

Thank you for your reply, that was exactly how I fixed this problem.
Have to use a variable and not property for it to work.

Will definitely look to upgrade in the near future.

Kind Regards,
Gerrit
Tags
General Discussions
Asked by
Gerrit
Top achievements
Rank 2
Answers by
Gerrit
Top achievements
Rank 2
Nikolay Datchev
Telerik team
Share this question
or