private static ICypherFluentQuery CommonMerge <T>( this ICypherFluentQuery query , T entity , string key , string mergeCql , List <CypherProperty> mergeOverride = null , List <CypherProperty> onMatchOverride = null , List <CypherProperty> onCreateOverride = null) where T : class { //A merge requires the properties of both merge, create and match in the cutdown object var mergeProperties = mergeOverride ?? CypherTypeItemHelper.PropertiesForPurpose <T, CypherMergeAttribute>(entity); var createProperties = GetCreateProperties(entity, onCreateOverride); var matchProperties = onMatchOverride ?? CypherTypeItemHelper.PropertiesForPurpose <T, CypherMergeOnMatchAttribute>(entity); dynamic mergeObjectParam = entity.CreateDynamic(mergeProperties); var matchParamName = GetMatchParamName(key); query = query.Merge(mergeCql); query = query.WithParam(matchParamName, mergeObjectParam); if (matchProperties.Count > 0) { var entityType = entity.GetType(); foreach (var matchProperty in matchProperties) { var propertyParam = key + matchProperty.JsonName; var propertyValue = GetValue(entity, matchProperty, entityType); query = query.OnMatch().Set(GetSetWithParamCql(key, matchProperty.JsonName, propertyParam)); query = query.WithParam(propertyParam, propertyValue); } } if (createProperties.Count > 0) { var createParamName = key + "OnCreate"; dynamic createObjectParam = entity.CreateDynamic(createProperties); query = query.OnCreate().Set(GetSetWithParamCql(key, createParamName)); query = query.WithParam(createParamName, createObjectParam); } return(query); }