dynamicquery

Remove objects from query if None or Null

谁说胖子不能爱 提交于 2021-01-28 00:48:46
问题 I am trying to build a query that takes form data and removes any None or " " submissions but I'm not sure how to approach the logic. Here is the code; @app.route('/filterassets', methods=['GET', 'POST']) def searchassets(): form = FilterAssetsForm() results = None if request.method == "POST": if form.validate_on_submit(): try: horsepower = form.horsepower_search.data voltage = form.voltage_search.data rpm = form.rpm_search.data results = Motor.query.filter_by(horsepower=horsepower, voltage

Dynamic query for creating where predicate with inner Collection

我只是一个虾纸丫 提交于 2020-01-22 23:03:08
问题 I am creating search capability for my MVC EF application. I am creating it using dynamic query. And following this method https://www.codeproject.com/Articles/493917/Dynamic-Querying-with-LINQ-to-Entities-and-Express Its for creating predicate for bool and string fields of entity. Main entity in my app is Applicant EDMX Applicant is following public partial class Applicant { public Applicant() { this.ApplicantEducations = new HashSet<ApplicantEducation>(); this.ApplicantSkills = new HashSet

Cypher query vs cypher dsl in spring data neo4j

╄→尐↘猪︶ㄣ 提交于 2020-01-16 19:18:08
问题 I want to know about neo4j dsl recommendation in Spring data neo4j framework. As of now I used to create repository interface extending from GraphRepository , NamedIndexRepository etc. and write my custom methods with my custom cypher query with @Query annotation as below: @Query(value="START root=node:__types__(className='com.data.EntityNode') WHERE root.id={0} and " + "root.type={1} return root") T findByIdAndType(String id, String type); above method works nicely as far as I consider the

To call SelectMany dynamically in the way of System.Linq.Dynamic

与世无争的帅哥 提交于 2020-01-13 05:09:28
问题 In System.Linq.Dynamic, there are a few methods to form Select, Where and other Linq statements dynamically. But there is no for SelectMany. The method for Select is as the following: public static IQueryable Select(this IQueryable source, string selector, params object[] values) { if (source == null) throw new ArgumentNullException("source"); if (selector == null) throw new ArgumentNullException("selector"); LambdaExpression lambda = DynamicExpression.ParseLambda(source.ElementType, null,

To call SelectMany dynamically in the way of System.Linq.Dynamic

筅森魡賤 提交于 2020-01-13 05:09:27
问题 In System.Linq.Dynamic, there are a few methods to form Select, Where and other Linq statements dynamically. But there is no for SelectMany. The method for Select is as the following: public static IQueryable Select(this IQueryable source, string selector, params object[] values) { if (source == null) throw new ArgumentNullException("source"); if (selector == null) throw new ArgumentNullException("selector"); LambdaExpression lambda = DynamicExpression.ParseLambda(source.ElementType, null,

How to call stored procedure in liferay?

佐手、 提交于 2019-12-24 05:46:22
问题 I am referring Using dynamic query in Liferay and using MySQL 5.5 but instead of custom queries involving multiple entities,we need to call a stored procedure. We have created a sample procedure delimiter // Create Procedure proc_check (OUT count INT) begin select count(*) into count from lg_office ; end// In default.xml,containing custom queries,we have used <sql id="de.uhh.l2g.plugins.service.persistence.ProducerFinder.findOfficeCount"> <![CDATA[ Call proc_check(@output) ]]> </sql> In the

Dynamic query with HibernateCritera API & Oracle - performance

一世执手 提交于 2019-12-20 04:47:54
问题 I have to use Hibernate and retrieve data from Oracle but the problem is, that the number of parameters passed to the query is not always the same. For the sake of simplicity let's consider the following query: select COL_1, COL_2, ..., COL_N from TAB_1 where COL_1 in (?, ?, ... ?) The number of parameters passed to in clause is between 1 and 500. If the number is about 1-50 it works quite fast, but for 200 it takes a few seconds to execute the query (parsing, creating explain plan, executing

How to write this Linq SQL as a Dynamic Query (using strings)?

余生颓废 提交于 2019-12-18 16:56:58
问题 Skip to the "specific question" as needed. Some background: The scenario: I have a set of products with a "drill down" filter (Query Object) populated with DDLs. Each progressive DDL selection will further limit the product list as well as what options are left for the DDLs. For example, selecting a hammer out of tools limits the Product Sizes to only show hammer sizes. Current setup: I created a query object, sent it to a repository, and fed each option to a SQL "table valued function" where

Spring Data MongoDB Repository - JPA Specifications like

天涯浪子 提交于 2019-12-18 06:58:28
问题 Is there something like JPA Specifications for Spring Data MongoDB Repositories? If not, how can I make dynamic queries with repositories? A classic scenario could be a search form with optional fields that the user will fill. 回答1: I found myself a way. The trick can be done using QueryDSL , in the following way: First, add the QueryDSL dependencies: <dependency> <groupId>com.mysema.querydsl</groupId> <artifactId>querydsl-mongodb</artifactId> <version>${querydsl-mongo.version}</version> <

Multirow subselect as parameter to `execute using`

血红的双手。 提交于 2019-12-13 04:15:32
问题 The multirow subselect will be used in the right hand side of the in operator in the where clause: create table t (a integer); insert into t (a) values (1), (9); drop function if exists f(); create function f() returns void as $$ begin execute ' select a from t where a in $1 ' using (select 1 union select 2); end;$$ language plpgsql; select f(); ERROR: more than one row returned by a subquery used as an expression CONTEXT: SQL statement "SELECT (select 1 union select 2)" PL/pgSQL function "f"