How do I use LINQ to update objects in one list from objects in a second list? My question is very similar to http://stackoverflow.com/questions/709560/linq-in-line-property-update-during-join except that, in my case, the second list is smaller than the parent list.
In other words, I want to update those members of the master collection ...
I am going to build a search function today, c# asp.net. i need a push go get it rolling. i use nhibernate linq. it would be nice to do this with linq query. it need to be kinda dynamic, i am going to have several search criterias like gender, email, name, age and some more.
this search query is only going to my customer object.
how ...
Restated question:
I have foo.
Foo has many fizzs.
Fizz has Foo.
Bar has one fizz.
I want to find foo, which has fizz with the highest count of bars that reference it using LINQ .
It would be perfect, if linq would be NHibernate.Linq compatible. But that's already a different story.
Old question:
I know - question is simple. I've ...
I have a string with semi-comma separated names:
string names = "Jane;Harry";
I also have a list of customer objects:
public class Customer
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
List<Customer> customers = new List<Customer>();
customers.Add(new Customer(){FirstName="John", LastName="Doe"}...
I am currently using groupby with a foreach loop to show a list of nested records.
However I want to us an id as the key, so that I can use it to make dynamic css selectors etc..
But I want to be able to show the name of each of the groups before the secondarly loop is iterated through.
I think the code will make it more clear.
Basic...
Hello Functional C# Friends,
So this time i am trying to compact my code and write in more functional , lambda style, as well as i would like to avaoid creating unneccessary lists and classes and let compiler do the work for me. I did manage to convert some small piece of code in functional way but after that i dont have much idea as ho...
In the below example, how can I easily convert eventScores to List<int> so that I can use it as a parameter for prettyPrint?
Console.WriteLine("Example of LINQ's Where:");
List<int> scores = new List<int> { 1,2,3,4,5,6,7,8 };
var evenScores = scores.Where(i => i % 2 == 0);
Action<List<int>, string> prettyPrint = (list, title) =>
{
...
I have used the single ampersand (&) in C# to mean "check the second conditional statement even if the first is false".
But the following seems to be a different meaning of & altogether, can anyone explain how i & 1 works in the following example?
List<int> scores = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8 };
var evenScores = scores.Whe...
I have two tables from two different Data Contexts. Although both tables are from the same database, two separate datacontexts exist.
Error msg: "The query contains references to items defined on a different data context."
How can I get around this? Any help is appreciated. Thanks.
...
I currently have a controller with the following ActionResult
public ActionResult Details(string sku)
{
Product p = _productRepository.GetProduct(sku);
return View("Details", p);
}
I would like to expand on the LINQ query to return the product before as well as the product after to the view. So instead of ...
Hi,
I have the following pretty simple linq query querying a linq to entities edmx.
(from i in ent.Inspectors select i).OrderBy(s => s.Surname).Skip((page - 1) * count).Take(count).ToList();
In Sql Server Profiler I can see that the exact same select query is being sent twice.
Can someone explain why?
Cheers,
Dave
...
How can I lazy load an association (EntitySet) in LINQ to SQL? You can't set Delay Loaded on Associations in the designer, and I couldn't find a DBML attribute for it either. I looked at DataLoadOptions to see if there was a way to lazy load them that way, but DataLoadOptions really just provides a way to mold the SQL that is generated f...
is there any ways to accomplish this? it is really annoying having to restart every time.
...
I'm building flat file content from collections of strings.
Example collection: A, B, C, D, E, etc.
I want to be able to output these values to a string with line feeds in one swoop with Linq if possible.
Sample Output:
A
B
C
D
E
etc.
Here's the VB.NET code that does the job currently:
For Each fieldValue As String In field.Va...
I would like to know what the easiest and shortest LINQ query is to return true if a string contains any number character in it.
Thanks
Jobi Joy
...
I have a products sales table that looks like this:
saleDate prod qty
10/22/09 soap 10
09/22/09 pills 05
09/25/09 soap 06
09/25/09 pills 15
I need to make the SUM of each MONTH so the final table would look like this:
saleDate prod qty
10/09 soap 10
09/09 ...
Here is my problem :
I have the following dictionary :
Dictionary<double, Dictionary<double, List<string>>>;
With LINQ I would like to first
1) Sort this dictionary in descending order, keep the first 20, and work with the second dictionary.
2) With the second dictionary I would like to sort it by descending order , keep the sorted...
Hi,
Based on this answer http://stackoverflow.com/questions/288810/get-the-subdomain-from-a-url, I am trying to use code.google.com/p/domainname-parser/ that will use Public Suffix List from publicsuffix.org to get subdomain and domain for managing my cookie collection.
In the current moment, Domainname-parser is the only .NET code I f...
Hi,
my code is:
List<Benutzer> users = (from a in dc.Benutzer
select a).ToList();
I need this code but I only want to select 3 of the 20 Columns in the "Benutzer"-Table.
What is the syntax for that?
...
Hi Chaps,
I use a DeatialsView with AutoGeberateColoums for my user administration.
Here my start code:
Business.UserHandling uh = new Business.UserHandling();
DAL.Benutzer user = uh.GetSingleUser(BenutzerID_Int);
List<DAL.Benutzer> listUser = new List<DAL.Benutzer>();
listUser.Add(user);
Detail...