Example #1
0
        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());
        }
Example #2
0
        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}");
            }
        }
Example #3
0
        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);
        }
Example #4
0
        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);
        }
Example #5
0
        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);
        }
Example #6
0
        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}";
            }
        }
Example #7
0
        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);
        }
Example #8
0
 public string[] SelectFields()
 {
     return(_document.SelectFields());
 }
Example #9
0
 public WholeDocumentSelector(IQueryableDocument mapping, IDocumentStorage <T> documentStorage)
     : base(mapping.SelectFields().Select(x => $"d.{x}").ToArray())
 {
     storage = documentStorage;
 }
Example #10
0
 public WholeDocumentSelector(IQueryableDocument mapping, IResolver <T> resolver)
     : base(mapping.SelectFields().Select(x => $"d.{x}").ToArray())
 {
     _resolver = resolver;
 }