我通过运行以下方法尝试获取结果集时收到错误/异常:
public IEnumerable<NeoProduct> GetAllProductsUnderCategory(int categoryId)
{
var query = neo.Cypher.Match("(c:Category{CategoryId:{id}})<-[*](p:Product)")
.WithParam("id", categoryId)
.Return(p => p.As<NeoProduct>()).Results;
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,它是一个返回NeoProducts列表的非常简单的方法.NeoProduct是一个简单的POCO,具有以下属性:
public int CategoryId { get; set; }
public string CategoryName { get; set; }
public int ParentCategoryId { get; set; }
Run Code Online (Sandbox Code Playgroud)
堆栈跟踪是:
[OverflowException: Value was either too large or too small for an Int64.]
System.Number.ParseInt64(String value, NumberStyles options, NumberFormatInfo numfmt) +14278344
System.String.System.IConvertible.ToInt64(IFormatProvider provider) +55
System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) +14285879
Neo4jClient.Serialization.CommonDeserializerMethods.CoerceValue(DeserializationContext context, PropertyInfo propertyInfo, JToken value, IEnumerable`1 typeMappings, Int32 nestingLevel) in D:\temp\tmpC806\Neo4jClient\Serialization\CommonDeserializerMethods.cs:101 …Run Code Online (Sandbox Code Playgroud) 我编写了一个小方法,其唯一目的是检查给定类的属性是否为null.如果属性为null,则创建它的新实例.我实际上已经设置了一个值,我被卡住了:
public static void CheckIfPropertyIsNull<TEntity>(SomeBusinessEntity someBusinessEntity) where TEntity : new()
{
var properties = typeof(SomeBusinessEntity).GetProperties();
foreach (PropertyInfo propertyInfo in properties)
{
Type currentType = propertyInfo.PropertyType;
if (currentType == typeof(TEntity))
{
var propertyData = propertyInfo.GetValue(someBusinessEntity, null);
if (propertyData == null)
{
object instance = Activator.CreateInstance(typeof(TEntity));
// And then?
//propertyInfo.SetValue(null, instance);
return;
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用SetValue()方法,但没有运气.