What am I missing here?
I want to do a simple call to Select() like this:
List<int> list = new List<int>();
//fill the list
List<int> selections = (List<int>)list.Select(i => i*i); //for example
And I keep having trouble casting it. What am I missing?
...
I want to get the distinct values in a list, but not by the standard equality comparison.
What I want to do is something like this:
return myList.Distinct( (x, y) => x.Url == y.Url );
I can't, there's no extension method in Linq that will do this - just one that takes an IEqualityComparer.
I can hack around it with this:
return myL...
I'm very new to Linq so bare with me. Can I return more than one item in a select? For instance I have a List of Fixtures (think football (or soccer for the yanks) fixtures). Each fixture contains a home and away team and a home and away score. I want to get all the teams that drew. I want to use something like
IEnumerable<Team> dre...
I have a collection of objects called Gigs.
Each Gig has an Acts collection.
Using Linq I want to query my collection of gigs to get all gigs where with an act that has an id of 7 for example.
act.id = 7;
So I started writting...
return from gig in qry
where gig.Acts //not sure how to do this bit
select gig;
But I'm...
I have several Stored Procedures that when added to my dbml, it seems that behind the scenes LINQ can not interpret the result set and will simply map the result as an int. I then have to create the result class myself which is a pain but also I have to go and change the designer file every time I add to my dbml because it will re-load ...
I have two documents both are similar but I need to find an elegant and efficient way to compare the two files and return the values in Doc #1 that don't exist in Doc #2.
XML Doc #1
<ids>
<id>1</id>
<id>2</id>
<id>5</id>
<id>6</id>
<id>7</id>
<id>8</id>
<id>9</id>
</i...
This should be pretty straight forward but I can't seem to get my newbie mind around it. I have a ASP.net page that needs to create a new database entry based on user input from a web form.
One control in the form is a DropDownBox that is databound to a LinqDataSource whose context is a LinqToSQL data class. The table it is bound to is...
The basic problem...
I have a method which executes the following code:
IList<Gig> gigs = GetGigs().WithArtist(artistId).ToList();
The GetGigs() method gets Gigs from my database via LinqToSql...
So, when GetGigs().WithArtist(artistId).ToList() is executed I get the following exception:
Member access 'ListenTo.Shared.DO.Artist Arti...
if i have two thousand webusers each sumbmitting a post to sqldb through website at the same time same tables, will linq handle this without any problems?
...
If I have something like:
var query = from children in _data.Children
where children.ChildId == childId
select new CustomModel.MyChild
{
ChildId = children.ChildId,
Name = children.ChildName
};
return query.FirstOrDefault();
Where I want the resultant object to be my custom model.
Can I handle the custom mo...
Using extension syntax I'm trying to create a left-join using LINQ on two lists that I have. The following is from the Microsoft help but I've modified it to show that the pets list has no elements. What I'm ending up with is a list of 0 elements. I assume that this is because an inner-join is taking place. What I want to end up with is ...
In normal condition, I can add schemas in the dbml file to empty database with code below.
But now when I run this code, I take the error "Cannot drop database "test" because it is currently in use." How can I do it?
Dim db As New UI_Class.UIData
If db.DatabaseExists Then
db.DeleteDatabase()
End If
db....
Say the object is as follows:
string Name
Dictionary<string,bool> Tags
Where tags is dynamic, but there is a list of tags stored in a Collection in the core data object.
I want to be able to display this in a datagrid like so:
Name tag1 tag2 tag3
Bob true true
John true true
I left out false, but that could be in ther...
Allow me to start with: I am a n00b on ASP.NET MVC. I love it, but I am a n00b.
I am trying to pass "complex" data back from a LINQ query. I understand how to use the data context and then just cast that data when I send it back, but when I do a more complicated LINQ query which returns an anonymous type, things break down.
I saw som...
Is Linq included in .net 2010
...
I have a list of records in my database and each record is associated with a zip code.
What is the "best-practice" for querying all the records in my database to find all entries that are within n miles of another zip code?
Each zip code has a lat/long associated with it in the database so I know I'll have to use that. However, I can'...
How do I write a sub-select in LINQ.
If I have a list of customers and a list of orders I want all the customers that have no orders.
This is my pseudo code attempt:
var res = from c in customers
where c.CustomerID ! in (from o in orders select o.CustomerID)
select c
...
I have the following dictionary declared:
private readonly Dictionary<int, Image> dictionary;
And I have a method, which is causing a compiler error:
public IQueryable<Image> Find(Func<Image, bool> exp)
{
return dictionary.Single(exp);
}
The error i get is:
Error 1 The type arguments for method 'System.Linq...
What (if any) is the difference between the results of the following two versions of this VB Linq query?
' assume we have an XElement containing employee details defined somewhere else
Dim ee = From e In someXML.<Employee> _
Select New With {.Surname = e.<Surname>, .Forename = e.<Forename>}
and
Dim ee = From e In someXML.<Employee> ...
The SQL server doing queries based COLLATE option, so you can define how comparision will be performed (case sensitive or not). You can do it when you creating table or during query execution.
How can I control collation during my LINQ to SQL queries? Will my queries be allways case insensitive when I will do table.Column == stringValue...