protected virtual IQueryBuilder GetQuery(Type type, PropertyStore val, object id, OrderedProcess <IQueryBuilder> processQuery) { if (id != null && !(id is string)) { throw new ArgumentException("Invalid id type " + id.GetType().FullName); } var query = QueryBuilderFactory.Instance.Create(); query.SqlConditionals.Add("DataType = @dataType"); query.SqlParameters.Add("@dataType", type.FullName); if (id != null) { query.SqlConditionals.Add("Path = @path"); query.SqlParameters.Add("@path", id); } else { query.SqlConditionals.Add("Path IS NULL"); } if ((Guid)val["Id"] == Guid.Empty) { // Initialise new ContentItem val["Path"] = id; val["DataType"] = type.FullName; val["Id"] = Guid.NewGuid(); if ((Guid)val["Identity"] == Guid.Empty) { val["Identity"] = Guid.NewGuid(); } } val.Do(kvp => query.SqlSets.Add(kvp.Key, kvp.Value)); query.PreservedFields.Add("Id"); query.PreservedFields.Add("Identity"); query = processQuery.Process(query); query.SqlTable = "ContentItems"; return(query); }
protected virtual IQueryBuilder GetQuery(Type type, PropertyStore val, object id, OrderedProcess<IQueryBuilder> processQuery) { if (id != null && !(id is string)) throw new ArgumentException("Invalid id type " + id.GetType().FullName); var query = QueryBuilderFactory.Instance.Create(); query.SqlConditionals.Add("DataType = @dataType"); query.SqlParameters.Add("@dataType", type.FullName); if (id != null) { query.SqlConditionals.Add("Path = @path"); query.SqlParameters.Add("@path", id); } else query.SqlConditionals.Add("Path IS NULL"); if ((Guid)val["Id"] == Guid.Empty) { // Initialise new ContentItem val["Path"] = id; val["DataType"] = type.FullName; val["Id"] = Guid.NewGuid(); if ((Guid)val["Identity"] == Guid.Empty) val["Identity"] = Guid.NewGuid(); } val.Do(kvp => query.SqlSets.Add(kvp.Key, kvp.Value)); query.PreservedFields.Add("Id"); query.PreservedFields.Add("Identity"); query = processQuery.Process(query); query.SqlTable = "ContentItems"; return query; }