Questions tagged [dynamicquery]

Use this tag for questions related to dynamic queries; queries that are built dynamically rather than provided as an explicit query string.

is usually found in questions related to SQL, C#, Drupal, Java, etc., so if you are about to use this, make sure you accompany it by the corresponding tag of your programming environment.

344 questions
33
votes
5 answers

How to set table name in dynamic SQL query?

I want to set table name in a dynamic SQL query. I tried successfully for parameter as following: /* Using sp_executesql */ /* Build and Execute a Transact-SQL String with a single parameter value Using sp_executesql Command */ /* Variable…
Neo
  • 15,491
  • 59
  • 215
  • 405
32
votes
1 answer

How to initialize Specification of Spring Data JPA?

I have a method that does a search with filters, so I'm using Specification to build a dynamic query: public Page searchFoo(@NotNull Foo probe, @NotNull Pageable pageable) { Specification spec = Specification.where(null); // is…
anat0lius
  • 2,145
  • 6
  • 33
  • 60
17
votes
2 answers

Spring Data MongoDB Repository - JPA Specifications like

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.
11
votes
5 answers

Dynamic where condition in LINQ

I have a scenario where I have to use a dynamic where condition in LINQ. I want something like this: public void test(bool flag) { from e in employee where e.Field("EmployeeName") == "Jhom" If (flag == true) { …
Shivi
  • 1,075
  • 9
  • 24
  • 42
11
votes
2 answers

Spring Data dynamic query

I'm trying to set up a dynamic query using spring data, basically I have an array with a bunch of characteristics and I need to assemble the query based on those characteristics, pretty much something like "WHERE characteristic = A AND…
Pablo Fallas
  • 781
  • 2
  • 7
  • 17
6
votes
3 answers

Getting all users with a Role in Liferay

I'm new to Liferay development in general, so feel free to point out if I'm going about stuff totally the wrong way. I'm trying to get a DynamicQuery object of all users within a certain group (I'll use this object to further filter another query…
Henrik Paul
  • 66,919
  • 31
  • 85
  • 96
6
votes
1 answer

How to cast a Linq Dynamic Query result as a custom class?

Normally, I do this: var a = from p in db.Products where p.ProductType == "Tee Shirt" group p by p.ProductColor into g select new Category { PropertyType = g.Key, Count = g.Count() } But I…
Zachary Scott
  • 20,968
  • 35
  • 123
  • 205
6
votes
2 answers

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

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…
Zachary Scott
  • 20,968
  • 35
  • 123
  • 205
5
votes
1 answer

How to pass an empty php variable in mongodb query

I want to create a dynamic mongodb query which insert each part of it's aggregation if the condition is true else don't inject that part. For example I want to check if the time is between 1AM till 8AM If yes then pass in the defined array to the…
Mohammad_Hosseini
  • 2,481
  • 3
  • 30
  • 53
5
votes
1 answer

Adding Where Condition to All Requests EF6

Most of my entities (not all) have two properties called CompanyId and Deleted. How would be possible to auto insert these two properties for all select requests instead of setting manually on every single query I have along the whole…
5
votes
3 answers

How to create a dynamic query from a list of fields?

I am trying to build a dynamic query using PHP and MySQL. What I have done is created a table (ie. field_relations) This field has 5 column field_name (the name of a field "ie. account_id, account_name....") display_label (The way how the field…
Jaylen
  • 39,043
  • 40
  • 128
  • 221
4
votes
4 answers

Dynamic WHERE clauses in a SqlDataSource

I'm using a SqlDataSource in a very simple application. I'm allowing the user to set several search parameters for the SDS's select command via TextBoxes, one TextBox per parameter (think txtFirstName, txtLastName, etc). I'm planning on using a…
Windy
  • 79
  • 1
  • 1
  • 9
4
votes
2 answers

Dynamic query for creating where predicate with inner Collection

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…
user786
  • 3,902
  • 4
  • 40
  • 72
4
votes
2 answers

XML ResultMap in MyBatis with association

I see this issue very strange descibed on google or stack. Let me explain. I have Result Maps in annotations in my interface method. Only in this particular case I need dynamic query, and that is the reason I decided to write the whole mapper for…
xross
  • 597
  • 4
  • 9
  • 25
4
votes
1 answer

How to convert deprecated IMongoQuery to a FilterDefinitionBuilder

I've got a Visual Studio C# project that's using the MongoDB driver v2.0, and I am attempting to update it to use driver v2.3.0. There's a section of code which builds a list of IMongoQuery entries based on the presence of various search fields,…
Alan
  • 3,715
  • 3
  • 39
  • 57
1
2 3
22 23