Hi
I have recently started off with LINQ and its amazing. I was wondering if LINQ would allow me to apply a function - any function - to all the elements of a collection, without using foreach. Something like python lambda functions.
For example if I have a int list, Can I add a constant to every element using LINQ
If i have a DB tabl...
Hello,
I have a linq query which returns the ID of a question based on the questions text.
This ID is then needed to be used to relate a date in a date table to that particular question. The question is already stored and the date is stored at a different time.
The problem is that the query returns the questionID as an anonymous type a...
I have a huge IQueryable that I want to export directly to Excel for data dumps, how would I do this?
I was trying to put it into a GridView and export from there, which works if I use only a chunk of the data, but if I use the whole IQueryable, nothing happens.
This is a table with 4k rows and each row has 70 or so columns.
Edit: CSV...
I have a exchange rate table. I need to get current rate and previous rate and then compare results.
I can get first record using FirstOrDefault.
When i using ElementAtOrDefault,error show "The query operator 'ElementAtOrDefault' is not supported". How can i get second record?
...
I am trying to construct a LINQ query, with expression trees, to do the following:
I have a field in my ItemCode table called Labels, an example of the data contained in this field is "lamps lighting chandelier".
I want to allow the user to type in some text, i.e. "Red Lamp", and be able to search the Labels field, of the ItemCode, tab...
Hi, I have a simple select from a typed dataset:
var productlist = from prds in dsProducts.sk_products.AsEnumerable()
join prdcat in dsProducts.sk_productscategories.AsEnumerable() on prds.Field<int>("productid") equals prdcat.Field<int>("productid") where prdcat.Field<int>("categoryid") == categoryid
...
Hi.
I have a small problem where I want to find the next "active" item in a list with linq. Then next "active" item is defined by a startDate and EndDate. Here is an example list.
//-- Create Lists of turns
IList<Turn> turns= new List<Turn>(){
new Turn(){Name = "Turn 1", StartDate = DateTime.Parse("2009-05-...
I have two tables which have a column in common , how can I retreive the first table where the values of it's column are not equal to the values of the column of the other table?
Here is an example:
table1ID | foo | fooBool table2ID | foo | fooin
---------------------------- -----------------------------
...
Using Linq To XML, how can I get the space_id value (720) from the xml below?
I am reading this but I think the namespace in the xml is my stumbling block.
<r25:spaces xmlns:r25="http://www.collegenet.com/r25" pubdate="2009-05-05T12:18:18-04:00">
<r25:space id="VE1QOjRhMDAyZThhXzFfMWRkNGY4MA==" crc="" status="new">
<r25:space_id>...
Hello,
Is there any function in F# similar to LINQ fluent syntax for sorting by multiple expressions:
myList.OrderBy(fun x->x.Something).ThenBy(fun x->x.SomethingElse)
I'd love something like:
myList
|> Seq.sort_by(fun x->x.Something)
|> Seq.then_by(fun x->x.SomethingElse)
Thx
...
I'm trying to build a way to get the key for a given piece of text in a given resx file at runtime.
Currently, I can open and read the file (Using ResXResourceReader) but I have to use a foreach to go over the entire file.
This could be a performance issue, as some of our resx files are fairly large (in the order of 2000 strings) and w...
After answering this question I put together the following C# code just for fun:
public static IEnumerable<int> FibonacciTo(int max)
{
int m1 = 0;
int m2 = 1;
int r = 1;
while (r <= max)
{
yield return r;
r = m1 + m2;
m1 = m2;
m2 = r;
}
}
foreach (int i in FibonacciTo(56).Where...
Is it possible to select all controls that inherit a particular abstract class with linq.
...
I'd like to do a subtraction of sets based on criteria. A pseudo-query would look like:
select table1.columnn1
,table1.column2
from table1, table2
where (table1.column1.value1 not in table2.column1
and
table1.column2.value2 not in table2.column2)
I can make it to about here:
dim list = From tbl1 In table1 Whe...
Is there a way to return a random row from a table using LINQToSQL?
...
Say I've got an array of User:
class User : IUserDowngraded
{
public Int32 Id { get; set; }
}
... with downgraded functionality done by casting the objects to a specific interface:
interface IUserDowngraded
{
Int32 Id { get; } // removes set functionality from property
}
... how would I cast those downgraded objects (IUserD...
I am working on an employee-scheduling system. I think I have the database setup pretty well, and have run into a snag on pulling the data for my database and getting it onto the page. I am using LINQ to make things easy on myself.
Here is the Object Relational Map.
Here is my Linq select statement:
protected void LinqSelecting(object...
Hi,
I am using LINQ to SQL in an ASP.NET project. While inserting the table I need to convert the values to the particular table object and I need to insert.
For that I created a new constructor in that table with parameter so that I can assign my value to that table object , the assign the functionality is working but while inserti...
Hello, I have a Question table which joins to a Solution table. The solutions are linked to the questions but in order to delete a question, i must delete the solutions for that question first and then delete the question itself.
I have a linq query that retrieves all solutions for a specified question however i am unsure how to proceed...
Say I create two sets of tuples like so:
Dim losSPResults As List(Of spGetDataResults) = m_dcDataClasses.spGetData.ToList
Dim loTupleKeys = From t In losSPResults Select t.key1, t.key2
'' Query on an existing dataset:
Dim loTupleExistingKeys = from t in m_losSPResults Select t.key3, t.key4
Now I want to perform set op...