I'm trying to see if there is a way to build a Linq statement that would choose based off available attributes in an element what the result would be, although not all attributes are always available.
For example, this would be a 'standard' element:
<box left="2" right="2" />
However, this is also perfectly valid:
<box left="3" />
...
I have a query similar to the following:
SELECT
users.id FROM users LEFT JOIN sales ON installations.customer = users.id
What I would like to say is something like "WHERE count(sales.id) > 4" - meaning that if the user has more than 4 sales assoc with them. I am not sure if I am going about this the wrong way or not though
...
I have a relatively simple query joining two tables. The "Where" criteria can be expressed either in the join criteria or as a where clause. I'm wondering which is more efficient.
Query is to find max sales for a salesman from the beginning of time until they were promoted.
Case 1
select salesman.salesmanid, max(sales.quantity)
from...
I have the following query:
DECLARE @IsStocked bit
SELECT * FROM Products p WHERE p.LastSeen > GETDATE() - 30
This returns all Products that have been seen within the last 30 days.
My question is, I would like the p.LastSeen > GETDATE() - 30 clause to only apply when @IsStocked = true.
This is part of a larger query, and I'd like...
According to the Wikipedia article on Google App Engine:
The where clause of select statements
can perform >, >=, <, <= operations on
one column only. Therefore, only
simple where clauses can be
constructed.
What does this mean?
...
Hi folks,
I've got a simple sql query that is trying to update a single row. The code came from some Linq-to-sql code (i used Profiler to grab it), but please don't worry about the source (L2S) ... that's irrelivant to the question.
Now, when i try and do an update with the where clause, I get 0 rows updated.
I then try and do a selec...
I have made myself an ExpressionBuilder class that helps me put together expressions that can be used as a predicate when doing Linq to Sql queries. It has worked great. However, I just discovered Expressions can only be used to filter on Tables, and not on EntitySets??Why on earth is this the case?
For example if I have Company and an ...
What exactly does a LINQ function return when there are no matches? Take the Where method, for example:
var numbers = Enumerable.Range(1, 10);
var results = numbers.Where(n => n == 50);
What would be in results at this point?
...
I've been battling this one for a while now. I have a stored proc that takes in 3 parameters that are used to filter. If a specific value is passed in, I want to filter on that. If -1 is passed in, give me all.
I've tried it the following two ways:
First way:
SELECT field1, field2...etc
FROM my_view
WHERE
parm1 = CASE WHEN @PARM...
I have a simple query which is returning records based on the field status not having certain values.
Lets say for arguments sake that the field can have values 1,2,3...10 and I want to return all records that don't have values 3, 7 and 9. Which of the following would be best to use?
Option 1.
SELECT `id` FROM `tbl` WHERE (`status` != ...
Hello guys.
This should be fairly simple, though I can't seem to find a single example.
I want to create a query looking like this:
SELECT column_name FROM table_name WHERE column_name IN (value1,value2,...)
As an option I could append OR-clauses to the end of the query.
The code I have written so far keeps blowing up with a Nullpoi...
I'm trying to use an array to set the where parameters for a Zend DB Table. I am trying to follow an example in the documentation:
$select = $table->select()->where(array('bug_status = ?' => 'NEW'));
I have a class that inherits Zend_Db_Table and am trying to select like the example:
$select = $this->select()->where(array('FirstName...
I've got a SQL query that joins a pricing table to a table containing user-provided answers. My query is used to get the price based on the entered quantity. Below is my SQL statement:
SELECT JobQuestion.Value, Price.Min, Price.Max, Price.Amount FROM Price
INNER JOIN JobQuestion
ON Price.QuestionFK=JobQuestion.QuestionFK
...
Edit2:
After finally being able to profile the two against each other, it appears that in my situation .AsQueryable() is slightly faster than Expression.Compile().
Original question:
I have implemented a cache of some database tables (as List<T>) that I need to query with the same Expression<Func<T, bool>> as I would use when querying a...
Hey so I've got the situation where I'm pulling a client back from the database and including all the case studies with it by way of an include
return (from c in db.Clients.Include("CaseStudies")
where c.Id == clientId
select c).First();
but what I want to do now is and a where clause on the included casestudies so tha...
I've hit an interesting snag (interesting to me at least). Below is a general idea of what my query looks like. Assume @AuthorType is an input to the stored procedure and that there are various specialized conditions each place I've put comments.
SELECT *
FROM TBooks
WHERE
(--...SOME CONDITIONS)
OR
(@AuthorType = 1 AND --...DIFFERENT ...
I'm trying to search several tables at once for a search term. My query is:
SELECT item.ItemID
FROM Inventory.Item item
JOIN Inventory.Category catR // each item can be in several categories
ON catR.ItemID = item.ItemID
JOIN Category.Category cat
ON cat.CategoryID = catR.CategoryID
...
Hi,
So I have managed to get this query working
List<string> listStatus = new List<string>() ;
listStatus.add("Text1");
List<string> listMerchants = new List<string>() ;
listMerchants.add("Text2");
from item in db.vw_Dropship_OrderItems
where listStatus.Contains(item.StatusCode)
&& listMerchants....
I have a query where I need to modify the selected data and I want to limit my results of that data. For instance:
SELECT table_id, radians( 25 ) AS rad FROM test_table WHERE rad < 5 ORDER BY rad ASC;
Where this gets hung up is the 'rad < 5', because according to codeigniter there is no 'rad' column. I've tried writing this as a cust...
Hi guys
I've got another simple one (I think) that's stumping me. I have written a method in one of my controls that gets the latest version of a file in a CMS given it's filename (i.e. regardless of what folder the file resides in). I found it useful enough that I thought I'd chuck it in my CMSToolbox class, but when I do this I can no...