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