private static ICypherFluentQuery CommonCreate <T>( this ICypherFluentQuery query , T entity , CreateOptions options , Func <string, string> getFinalCql) where T : class { if (options == null) { options = new CreateOptions(); } var createProperties = GetCreateProperties(entity); var identifier = entity.EntityParamKey(options.Identifier); var intermediateCreateCql = GetMatchWithParam(identifier, entity.EntityLabel(), createProperties.Count > 0 ? identifier : ""); var createCql = getFinalCql(intermediateCreateCql); var dynamicOptions = new CreateDynamicOptions { IgnoreNulls = true }; // working around some buug where null properties are blowing up. don't care on create. var cutdownEntity = entity.CreateDynamic(createProperties, dynamicOptions); query = query.Create(createCql); if (createProperties.Count > 0) { query = query.WithParam(identifier, cutdownEntity); } return(query); }
private static Dictionary <string, object> CreateDynamic <TEntity>( this TEntity entity , List <CypherProperty> properties , CreateDynamicOptions options = null) where TEntity : class { if (options == null) { options = new CreateDynamicOptions(); } var type = entity.GetType(); var propertiesForDict = properties.Select( prop => new { Key = prop.JsonName , Value = GetValue(entity, prop, type) } ).ToList(); if (options.IgnoreNulls) { propertiesForDict.RemoveAll(p => p.Value == null); } return(propertiesForDict.ToDictionary(x => x.Key, x => x.Value)); }