This error is being thrown when running a Linq query over a List.
I am using Unity3D 3.0 with C# (Unity3D uses Mono 2.6). Unity3D, as far as I know, is single-threaded. It works by attaching "scripts" (c# .cs files) that inherit a baseclass, to a "GameObject". Also, Unity controls instantiation and serialization of scripts so you can't ...
I’m creating a small application (a phonebook), actually
I already created it using ms access as a database, but now, I’m learning XML and planning to use it as a database for this app (just for fun and educational purposes).
Here’s the diagram in my access database.
And I created two XML files with the same structure as for the tw...
Maybe a little tricky, but I wonder why. In System.Linq.Enumerable.cs of System.Core.dll we have:
public static int Count<TSource>(this IEnumerable<TSource> source);
In my code I'm doing something evil:
namespace Test
{
public static class Extensions
{
public static int Count<TSource>(this IEnumerable<TSource> source)
...
So i recently learned this new trick of using Func Delegate and Lambda expression to avoid multiple validation if statements in my code.
So the code looks like something like
public static void SetParameters(Dictionary<string,object> param)
{
Func<Dictionary<string, object>, bool>[] eval =
{
...
foreach (Feature fe in features)
{
if (fileNames.Any(file => file.Contains(fe.FeatureName)))
{
fe.MatchCount = fe.MatchCount == 0 ? 1 : fe.MatchCount;
}
}
...
I was thinking about the way linq computes and it made me wonder:
If I write
var count = collection.Count(o => o.Category == 3);
Will that perform any differently than:
var count = collection.Where(o => o.Category == 3).Count();
After all, IEnumerable<T>.Where() will return IEnumerable<T> which doesn't implement Count property, so...
Can I do either of these using LINQ:
1. Check that each element in an IEnumerable<string> has the correct extension. If not, throw exception.
foreach(var filepath in filepaths)
if(Path.GetExtension(filepath) != @".xml")
throw new ArgumentException(...);
2. Take an IEnumerable<string> and serialise all of its elements...
I'm having a Structure like
X={ID="1", Name="XX",
ID="2", Name="YY" };
How to dump this data to a DataGridView of two columns
The gridView is like
ID | Name
Can we use LINQ to do this. I'm new to DataGridView Pleaese help me to do this..
Thanks in advance
...
I have a Linq extension method to dynamically filter Linq queries using string values. For example: query.WhereHelper("columName", ">", 1). I could use many different filter operators like GreaterThan or NotEqual etc. but not "Like". There is no Expression.Like or Expression.StartsWith etc. How can I implement Like operator to my Express...
class Foo
{
int PrimaryItem;
bool HasOtherItems;
IEnumerable<int> OtherItems;
}
List<Foo> fooList;
How do I get a list of all item ids referenced inside fooList?
var items = fooList
.Select(
/*
f => f.PrimaryItem;
if (f.HasOtherItems)
AddRange(...
I have a "Product" and a "Benefit" class which is shown below:
Now, I want to query a collection of products from within my view. I've created a LINQ query that gets the products but I want to get at the collection of benefits that belong within the product.
Code within my view (however this just iterates each product and I need to ite...
Background : We are using VS2008, ASP.NET .NET 3.5 and Entity Framework, with a SQL 2000 database. I am using SQL Profiler 2005 to capture LINQ sp_executesql statements on a SQL 2000 server.
Problem : In SQL Profiler the sp_executesql @stmt parameter is being randomly truncated; the @stmt SQL is normally rather large as I'm querying acr...
Hi,
In my Parent Child scenario, I need to get the custom list of all the customers with their total number of orders and orderitems.
A Customer can have many orders and orders can have many OrderItems. I need to write a query which returns me the collection of entity Objects which has the Customer Entity and Total Orders and Total Orde...
Hi, i want apply my linq query with 3 table joined to EntityDataSource at codebehind,I found this link but i want use 3 table
http://msdn.microsoft.com/en-us/library/ee404748.aspx
...
I have
IEnumerable<A> and IEnumerable<B>
I want to Group Join based on whether A.Test(B) returns true.
The keyselector funcs do not seem to do this as the KeySelectors need to return keys of the same type so that they can be checked for equality.
Is there something I'm missing here?
...
Hi,
does anyone know if is possible to add 2 entities into EF model from 2 DB.
If not, what suggestions can you gave me to build a query that affects 2 databases
...
I'm digging in in my Microsoft Visual Studio Documentation and I found this article under C# Reference (ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.en/dv_csref/html/df01e266-5781-4aaa-80c4-67cf28ea093f.htm), It's about Interface Interface. Here's the example code:
class SelectSample1
{
static void Main()
{
//Crea...
The following simple LINQ code
string[] words = { "hello", "wonderful", "linq", "beautiful", "world" };
// Get only short words
var shortWords =
from word in words
where word.Length <= 5
select word;
// Print each word out
shortWords.Dump();
can be translated into python using list comprehension as follows.
words = ["hello",...
Possible Duplicate:
LINQ Inner-Join vs Left-Join
How can i implement left join in LINQ?
plz provide me sample code.
...
how can i implement left outer join in following code:
var showmenu = from pag in pagerepository.GetAllPages()
join pgmt in pagerepository.GetAllPageMeta()
on pag.int_PageId equals pgmt.int_PageId
where (pag.int_OrganizationId == layoutrep.GetSidebarDetailById(SidebarDetailsId).int_Organizat...