How would I convert this query from SQL to Linq:
SELECT status As 'Status',
count(status) As 'Count'
FROM tbl_repair_order
WHERE contract = 'con' and
(status = 'Parts Arr' or
status = 'NA' or
status = 'New Call' or
status = 'Parts Ord' or
status = 'Parts Req' or
status = 'F Work')
G...
I have a DataTable that is filled from a stored procedure. I am doing a query on the DataTable using a groupby so that I can implement a ListView within a ListView. (Matt Berseth - Building a Grouping Grid with the ASP.NET 3.5 LinqDataSource and ListView Controls)
My Query in my codebehind:
var query = from c in dtTaskOrder.AsEnumerabl...
I have two lists, one which is a subset of the other.
List 1: A, B, C, D, E
List 2: B, D, E
I'd like to end up with a single collection of the superset with items contained in the subset flagged. This seems to be the sort of thing LINQ could do, but I'm not sure of the syntax.
Result: A, false
B, true
C, false
...
What is the best CRUD design pattern for an editable grid that will be databound to a joined query derived from LINQ?
Background
It's probably irrelevant whether I'm using Telerik's radGridView because this situation may pertain to any list control but I thought that I'd mention that if it helps. At any rate, I have two tables. One tab...
I'm trying to loop over distinct values over a dictionary list:
So I have a dictionary of key value pairs .
How do I get just the distinct values of string keys from the dictionary list?
...
Hi,
What linq features are currently not supported in SS3? Can't seem to find a list.
Ta,
Bob
...
I have the following SQL , how do I implement this in LINQ (c# please :))
SELECT a.Category, a.Description, a.Item, a.[Value], a.Loading, a.MaxDiscount, MIN(b.EffectiveDate) AS FromDate, a.EffectiveDate AS EndDate, a.SortOrder, a.ID
FROM List a
LEFT OUTER JOIN List b ON a.[Value] = b.[Value] AND a.Category = b.Category AND a.Des...
My table structure is this
Orders
------
Id int identity
OrderDate smalldatetime
OrderStatusid tinyint
Products
--------
Id int identity
Name varchar(50)
OrderDetails
------------
Id int identity
OrderId int (fkey)
ProductId int (fkey)
Amount decimal
Rate decimal
I am trying to an insert operation using Entity Framework using the c...
I have created the following LINQ query to demonstrate the problem:
string[] dateStrings = new string[] { "2009-07-20 13:00:00", "2009-07-20 16:00:00", "2009-07-20 09:00:00" };
DateTime dateValue = DateTime.MinValue;
var results =
from dateString in dateStrings
where DateTime.TryParse(dateString, out dateValue)
orderby...
How to delete multiple records in linq with multiple conditions?
...
I have a list of records with the following structure: (Simplified example!)
class Rate
{
string Code;
double InterestFrom;
double InterestTo;
double IncomeFrom;
double IncomeTo;
double Value;
}
And yes, I have a List<Rate> defined. I need to convert this list to the following simplified structure:
class RateL...
SQL query:
select ApplicationNumber,pri_indicator,count(*) from customer
group by ApplicationNumber,pri_indicator
How do I do this in LINQ?
I see plenty of results on using a simple group by to count a single field, but can't seem to find any or figure out how to do multiple fields.
...
I have the following code:
newsplit.ToList().ForEach(x => x = "WW");
I would expect that all elements in the list are now "WW" but they are still the original value. How come? What do I have to do different?
...
In reporting tools like Crystal Reports, there are ways to take denormalized data and group it by a particular column in the data, creating row headings for each unique item in the specified column.
If I have this:
Category1 Data1
Category1 Data2
Category1 Data3
Category2 Data4
Category2 Data5
Category2 Data6
The re...
I have created a bass class in LinqToSql which has 2 sub-classes. I need to assign a different stored procedure to each of the sub-classes custom update methods. Doing this is fine, but I get an error of "Invalid object name 'xxx'".
e.g.
DataClasses1DataContext dc = new DataClasses1DataContext();
Class2 c2 = new Class2() { ID = 1, N...
I have an ItemCollection that I'd like to query using LINQ. I tried the following (contrived) example:
var lItem =
from item in lListBox.Items
where String.Compare(item.ToString(), "abc") == true
select item;
Visual Studio keeps telling me Cannot find an implementation of the query pattern for source type 'System.Windows.C...
I have IQueryable<someClass> baseList
and List<someOtherClass> someData
What I want to do is update attributes in some items in baseList.
For every item in someData, I want to find the corresponding item in baselist and update a property of the item.
someOtherClass.someCode == baseList.myCode
can I do some type of join with Linq and...
I have a piece of code that makes the Visual Studio 2008 IDE run very slow, consume vast amounts of memory and then eventually causes it to crash. I suspect VS is hitting an OS memory limit.
The following code is not my real application code, but it simulates the problem. Essentially I am trying to find the minimum value within a tree u...
Hi, I'm trying to write some generic code in VB.NET that determines whether or not a SQL server database table contains an identity column and, if so, to return the name of that column.
I'm working in Visual Basic 2008 Express and have created a SQL database, "MyDatabase" with 1 table called "MyTable". Within that table, I've got 3 col...
Hi,
I am attempting to select from a List using a linq expression where the range variable is evaluated in a static method that returns boolean. I would like to select the range variable that returns true when the range variable is evaluated using the method.
var result = from rangeVariable in DataSource
where (rangeVariab...