Tag: c

49 votes
10 answers
1.2K views
Which method performs better: .Any() vs .Count() > 0?

in the System.Linq namespace, we can now extend our IEnumerable's to have the Any() and Count() extension

avatar
Luis
0 1 0 9
asked 07 September, 2021
60 votes
20 answers
3.1K views
Dynamic LINQ OrderBy on IEnumerable<T> / IQueryable<T>

I found an example in the VS2008 Examples for Dynamic LINQ that allows you to use a sql-like string (e.g. Orde

avatar
Patsy
0 1 0 9
asked 07 September, 2021
58 votes
14 answers
536 views
Using LINQ to remove elements from a List<T>

Say that I have LINQ query such as: var authors = from x in authorsList where x.firstname == "B

avatar
Lawanda
0 1 0 9
asked 07 September, 2021
57 votes
10 answers
991 views
IEnumerable vs List - What to Use? How do they work?

I have some doubts over how Enumerators work, and LINQ. Consider these two simple selects: List<Animal>

avatar
Eddie
0 1 0 9
asked 07 September, 2021
58 votes
12 answers
837 views
LINQ Aggregate algorithm explained

This might sound lame, but I have not been able to find a really good explanation of Aggregate. Good means s

avatar
Fabian
0 1 0 9
asked 07 September, 2021
60 votes
22 answers
2.8K views
LINQ equivalent of foreach for IEnumerable<T>

I'd like to do the equivalent of the following in LINQ, but I can't figure out how: IEnumerable<

avatar
Yolando
0 1 0 9
asked 07 September, 2021
60 votes
14 answers
3K views
When to use .First and when to use .FirstOrDefault with LINQ?

I've searched around and haven't really found a clear answer as to when you'd want to use .Firs

avatar
Sena
0 1 0 9
asked 07 September, 2021
53 votes
14 answers
907 views
Group By Multiple Columns

How can I do GroupBy multiple columns in LINQ Something similar to this in SQL: SELECT * FROM <TableName>

avatar
Nereida
0 1 0 9
asked 07 September, 2021
63 votes
23 answers
279 views
LINQ query on a DataTable

I'm trying to perform a LINQ query on a DataTable object and bizarrely I am finding that performing such

avatar
Dorian
0 1 0 9
asked 07 September, 2021
57 votes
10 answers
2K views
Group by in LINQ

Let's suppose if we have a class like: class Person { internal int PersonID; internal string c

avatar
Omar
0 1 0 9
asked 07 September, 2021
62 votes
14 answers
1.3K views
Returning IEnumerable<T> vs. IQueryable<T>

What is the difference between returning IQueryable<T> vs. IEnumerable<T>, when should one be pref

avatar
Leonardo
0 1 0 9
asked 07 September, 2021
53 votes
19 answers
2.2K views
Difference Between Select and SelectMany

I've been searching the difference between Select and SelectMany but I haven't been able to find a s

avatar
Renaldo
0 1 0 9
asked 07 September, 2021
64 votes
22 answers
1.3K views
LINQ&apos;s Distinct() on a particular property

I am playing with LINQ to learn about it, but I can't figure out how to use Distinct when I do not have a

avatar
Bryan
0 1 0 9
asked 07 September, 2021
51 votes
9 answers
3.1K views
Returning a file to View/Download in ASP.NET MVC

I'm encountering a problem sending files stored in a database back to the user in ASP.NET MVC. What I wan

avatar
Roger
0 1 0 9
asked 07 September, 2021
66 votes
9 answers
1.1K views
How to pass json POST data to Web API method as an object?

ASP.NET MVC4 Web API application defines post method to save customer. Customer is passed in json format in PO

avatar
Wilfredo
0 1 0 9
asked 07 September, 2021
64 votes
6 answers
335 views
HTML.ActionLink vs Url.Action in ASP.NET Razor

Is there any difference between HTML.ActionLink vs Url.Action or they are just two ways of doing the same thin

avatar
Robt
0 1 0 9
asked 07 September, 2021
62 votes
6 answers
2K views
How can I get the client&apos;s IP address in ASP.NET MVC?

I'm totally new to the ASP.NET MVC stack, and I was wondering what happened to the simple Page object and

avatar
Solomon
0 1 0 9
asked 07 September, 2021
65 votes
8 answers
2.4K views
How to use dashes in HTML-5 data-* attributes in ASP.NET MVC

I am trying to use HTML5 data- attributes in my ASP.NET MVC 1 project. (I am a C# and ASP.NET MVC newbie.) &

avatar
Charis
0 1 0 9
asked 07 September, 2021
70 votes
4 answers
2.7K views
ValidateAntiForgeryToken purpose, explanation and example

Could you explain ValidateAntiForgeryToken purpose and show me example about ValidateAntiForgeryToken in MVC 4

avatar
Tuan
0 1 0 9
asked 07 September, 2021
60 votes
23 answers
2K views
Html.ActionLink as a button or an image, not a link

In the latest (RC1) release of ASP.NET MVC, how do I get Html.ActionLink to render as a button or an image ins

avatar
Frederick
0 1 0 9
asked 07 September, 2021