c# - Dynamic LINQ cast to nullable -
Code> var q = sess.Query & lt; Users & gt; (). Select "Person (Id, Login, Person.Id as PersonId)");
NullReferenceException throws when users are in the database with the user. Person == null
This solves the problem:
var Q = sess.Query & lt; Users & gt; (). Select (new {id, login, PersonId = (long?) Person.Id}); But I need something like this var q = sess.Query & lt; Users & gt; (). Choose "(ID, Login, (Long?) Person.Id as individual ID)"); Because selection expression is generated dynamically. Unfortunately Dynamic LINQ does not seem to cast (long?): (
What should I do? Thanks in advance!
==== Edit === = OK, I understand two things: 1. Dynamic LINQ is not long, only does not know about 64. 2. Not Cast (Int 64) But 'Int 64 (some) 'then the whole code should be
sess.Query (). ("New ID (Login, Int64? Person.Id) PersonId As "); But it still is my poo The problem does not resolve because the NHibernate no longer fails, the query [SQL: SQL not available], and the NullReference internal exception could not be executed.
Now in my example cast can be made as 'int64'? Person.Id '. This is not a "normal" cutting syntax, but it works for me like a magic dynamic expression parser is very good but unfortunately it is not favorable for the C # cast syntax.
In addition to this, I registered the small type names of dynamic cs such as "long", "int" etc.
The revised source can be downloaded here :.
Comments
Post a Comment