public static string[] ToSelectFields(string tableAlias, IQueryableDocument includedMapping, ISelector <TSearched> inner) { var innerFields = inner.SelectFields(); var outerFields = includedMapping.SelectFields().Select(x => $"{tableAlias}.{x}"); return(innerFields.Concat(outerFields).ToArray()); }
public void ConfigureCommand(CommandBuilder sql) { sql.Append("select "); var fields = _mapping.SelectFields(); sql.Append(fields[0]); for (int i = 1; i < fields.Length; i++) { sql.Append(", "); sql.Append(fields[i]); } sql.Append(" from "); sql.Append(_mapping.Table.QualifiedName); sql.Append(" as d where id = :"); var parameter = sql.AddParameter(_id); sql.Append(parameter.ParameterName); if (storage.TenancyStyle == TenancyStyle.Conjoined) { sql.Append($" and {TenantWhereFragment.Filter}"); } }
public DocumentStorage(DocumentMapping document) { _mapping = document; _document = document; Fields = document; TableName = document.Table; _defaultWhere = document.DefaultWhereFragment(); _selectClause = $"select {_document.SelectFields().Select(x => $"d.{x}").Join(", ")} from {document.Table.QualifiedName} as d"; _loaderSql = $"select {document.SelectFields().Join(", ")} from {document.Table.QualifiedName} as d where id = :id"; _loadArraySql = $"select {document.SelectFields().Join(", ")} from {document.Table.QualifiedName} as d where id = ANY(:ids)"; if (document.TenancyStyle == TenancyStyle.Conjoined) { _loaderSql += $" and {TenantWhereFragment.Filter}"; _loadArraySql += $" and {TenantWhereFragment.Filter}"; } QueryableDocument = document; UseOptimisticConcurrency = document.UseOptimisticConcurrency; _setter = LambdaBuilder.Setter <T, TId>(document.IdMember); }
public void ConfigureCommand(NpgsqlCommand command) { var parameter = command.AddParameter(_id); var sql = $"select {_mapping.SelectFields().Join(", ")} from {_mapping.Table.QualifiedName} as d where id = :{parameter.ParameterName}"; command.AppendQuery(sql); }
public void ConfigureCommand(CommandBuilder sql) { sql.Append("select "); var fields = _mapping.SelectFields(); sql.Append(fields[0]); for (int i = 1; i < fields.Length; i++) { sql.Append(", "); sql.Append(fields[i]); } sql.Append(" from "); sql.Append(_mapping.Table.QualifiedName); sql.Append(" as d where id = :"); var parameter = sql.AddParameter(_id); sql.Append(parameter.ParameterName); }
public DocumentStorage(DocumentMapping document) { _document = document; Fields = document; TableName = document.Table; _defaultWhere = document.DefaultWhereFragment(); _selectClause = $"select {_document.SelectFields().Join(", ")} from {document.Table.QualifiedName} as d"; _loaderSql = $"select {document.SelectFields().Join(", ")} from {document.Table.QualifiedName} as d where id = :id"; _loadArraySql = $"select {document.SelectFields().Join(", ")} from {document.Table.QualifiedName} as d where id = ANY(:ids)"; if (document.TenancyStyle == TenancyStyle.Conjoined) { _loaderSql += $" and {TenantWhereFragment.Filter}"; _loadArraySql += $" and {TenantWhereFragment.Filter}"; } }
public DocumentStorage(DocumentMapping document) { _mapping = document; _document = document; Fields = document; TableName = document.Table; _defaultWhere = document.DefaultWhereFragment(); _idType = TypeMappings.ToDbType(typeof(TId)); _selectClause = $"select {_document.SelectFields().Select(x => $"d.{x}").Join(", ")} from {document.Table.QualifiedName} as d"; _loaderSql = $"select {document.SelectFields().Join(", ")} from {document.Table.QualifiedName} as d where id = :id"; _loadArraySql = $"select {document.SelectFields().Join(", ")} from {document.Table.QualifiedName} as d where id = ANY(:ids)"; if (document.TenancyStyle == TenancyStyle.Conjoined) { _loaderSql += $" and {TenantWhereFragment.Filter}"; _loadArraySql += $" and {TenantWhereFragment.Filter}"; } QueryableDocument = document; UseOptimisticConcurrency = document.UseOptimisticConcurrency; _setter = LambdaBuilder.Setter <T, TId>(document.IdMember); DeleteFragment = _mapping.DeleteStyle == DeleteStyle.Remove ? (IOperationFragment) new HardDelete(this) : new SoftDelete(this); }
public string[] SelectFields() { return(_document.SelectFields()); }
public WholeDocumentSelector(IQueryableDocument mapping, IDocumentStorage <T> documentStorage) : base(mapping.SelectFields().Select(x => $"d.{x}").ToArray()) { storage = documentStorage; }
public WholeDocumentSelector(IQueryableDocument mapping, IResolver <T> resolver) : base(mapping.SelectFields().Select(x => $"d.{x}").ToArray()) { _resolver = resolver; }