I realize this is partially subjective, but I'm generally curious as to community opinion and have not been able to successfully find an existing question that tackles this issue.
I am in a somewhat religious debate with a fellow coworker about a particular Select statement in a L2EF query.
.Select(r =>
{
r.foo.Bar = r.bar;
r.f...
I have 3 panels:
<asp:Panel ID="ParentPanel" runat="server">
<asp:Panel ID="AnnoyingPanel" runat="server">
<asp:Panel ID="P" runat="server">
</asp:Panel>
</asp:Panel>
</asp:Panel>
How can I check if P is child of ParentPanel? Is there some LINQish way to do it?
Is there some more optimized way than the one I p...
I have a class called Questions. This Questions has properties QuestionID and QuestionAnswer. While iterating through this List of Question in foreach, I have to find .QuestionID = 12. If I find .QuestionID = 12 then I have to immediately assign a value to .QuestionAnswer = "SomeText" of .QuestionID = 14.
I don't want iterate again in...
I have read all other posts and have been googling this for the last 2 hours! I started WCF Data Services about 3 hours ago btw.
My service is on an asp.net4 app, the ado entity model exposes an sql server db.
Here is FasDataService.svc.cs
public class FasDataService : DataService<FASStoreEntities>
{
public static void InitializeSe...
What is the quickest way to find out which .net framework linq methods (e.g .IEnumerable linq methods) are implemented using deferred execution vs. which are not implemented using deferred execution.
While coding many times, I wonder if this one will be executed right way. The only way to find out is go to MSDN documentation to make su...
For example:
var query = from c in db.Cars select c;
foreach(Car aCar in query)
{
Console.WriteLine(aCar.Name);
}
How would this translate once it is compiled? What happens behind the scenes?
...
I am aggregating multiple List's into one List and would like to make it distinct based on one of the properties of Foo (Foo.Prop1).. I do not have access to modify Foo's Equality comparer.
Dictionary<string, List<Foo>> fooDictionary = new Dictionary<string, List<Foo>>();
List<Foo> foovals = (from e in fooDictionary
...
The aspx.cs Code:
the code itself is pretty big, and the code here is fictional, but it looks (the important part) like this:
foreach (Transaction trans in vTransactionList)
{
switch (trans)
{
case 201: codehere; break;
case 202: codehere; break;
case 203:
...
I have the following two database tables. A group contains multiple members.
Groups: Id (int) | Name (int)
Members: Id (int) | GroupId (int) | IsExpert (bit)
I need to write a linq to sql query that returns the Groups that has no experts. Need some help
...
I have a string array:
string[] Animals = {"Cat", "Dog", "Fish"};
I then want to determine which element contains the sequence "is" and return that entire element; in this case "fish"
If I want to find "gh", it does not exist in the list, so it should return the first element, in this case "Cat"
I've tried this linq code, but i don'...
I have a basic datatable, it can be completely generic for this example, except for that it contains a Username column.
I'd like to have a simple textbox and a button that performs a similarity search on the Username field. I know I can use the .Contains() method and it will translate to LIKE in sql, but is this the correct way of doin...
I have a function, Name(int, DateTime), that I'd like to use in a linq2sql query.
Its a simple function that computes the difference between the passed in DateTime object and DateTime.Now using a TimeSpan. I then do some basic math stuff with .TotalHours and the passed in int. The most complicated function is Math.Pow(double,double)....
Is there any library or custom control that allows to construct LINQ to Objects (IEnumerable collection) queries at run-time from text, it would be nice to have IntelliSense support, like it is in Visual Studio code editor. I need to code CustomControl similar to http://xte.codeplex.com/ with IntelliSense and some other features that wi...
Hi
I have a situation where I receive an XML (document) file from an external company. I need to filter the document to remove all data I am not interested in.
The file is about 500KB but will be requested very often.
let say the following file:
<dvdlist>
<dvd>
<title>title 1</title>
<director>directory 2</director>
<p...
Hi,
Why is var excludes = users.Except(matches); not excluding the matches?
What is the proper way if I want the equality comparer to use only the ID? Examples would be appreciated.
public class User
{
public int ID { get; set; }
public string Name { get; set; }
public override string ToString()
{
return ID.T...
public partial class MembershipModule : BaseEntity<MembershipModule>
{
/// <summary>
/// Returns wheter a module is accessible
/// </summary>
public static bool IsAccessible(MembershipModule module)
{
// In absence of a module, no security applies to the page
if(module == null)
return true;...
Hi folks,
Update - I fixed the query below. I had the wrong query/error statement :(
I have the following statement:
var posts = BlogPostRepository.Find()
.Where(x => x.Tags.Where(y => y.Name == tag))
.ToList();
It's giving me a compile time error with the 2nd (inner) Where clause, saying :-
Error 1 Cannot convert...
I have a table in a db that has a structure like this:
Date
{
ID,
Username,
Label,
DateTime
}
I want to be able to perform a basic .Contains search in linq on the Username and Label columns, but there's a catch. I'd like to order by the number of LIKE matches. Here is what I mean by this:
If I have an instance of Da...
I have a fairly complicated linq query that returns an item and a string[] of one column in the item's many-to-many relationship.
So I return an anonymous type sort of like this:
var q = from k in db.Items
join m in db.ManyRel on k.Id equals m.ItemID
select new
{
k,
list = (from t in m
...
var tmpProjection = myCollection.ToLookup(t => t.SomeBoolValue);
var listOneFinal = tmpProjection[true];
var listTwo = tmpProjection[false];
First question, is there a way to assign it to listOne and listTwo in some shorter way, I know I'm being pedantic here, ... just asking.
Now,
var listThree = listTwo.ToLookup(t => t.SomeOtherBoo...