I've created a simple extension method on the string type:
public static bool Contains(this string word, string[] values)
{
foreach(string s in values)
{
if(!word.Contains(s))
return false;
}
return true;
}
now, I've got a linq query that looks like this:
public static IEnumerable<ISearchable> Sea...
This question (LINQ and a natural sort order…) talks about how to implement natural sorting in Linq using an IComparer. I've used this successfully in the past with IEnumerables, but I am unable to make it work in Linq-to-SQL expressions. Is this because the specific overload of .OrderBy() that takes an IComparer is not supported by Li...
Can someone please help me?
I'm trying to extract the PostalCode, Latitude and Longitude values from the XML below using LINQ. My efforts are resulting in a null IEnumerable !
The XML has been retuned from the BING REST server.
I'm sure it's not hard, it's just my LINQ is poor.
Thanks in advance
<?xml version="1.0"?>
<GeocodeFeed >
<G...
Select Top(8) * from products order by CreatedOn desc can u convert this query to Linq List
where product is a table in sql Created on is a dateTime comumn..
...
What is the difference between
var q_nojoin = from o in one
from t in two
where o.SomeProperty == t.SomeProperty
select new { o, t };
and
var q_join = from o in one
join t in two on o.SomeProperty equals t.SomeProperty
select new { o, t };
They seem to give me t...
Hi,
This is my SQL table:
i
d person datetime status description1 description2
----------- -------------------- ----------------------- ---------- --------------- ---------------
1 personA 2010-01-01 20:00:00.000 A desc1 desc2
2 personA 2010-01-01 21:00:00.000 B desc3 desc4...
I have issue with table "Reality" which is not found, when I type "db" and press dot it is not suggested to me and even when I type it manually it is not found.
DataClasses1DataContext db = new DataClasses1DataContext();
var query = db.Reality
I also could not see it in Object browser
Even when object "Reality" is alone...
I am relatively new to programming so be gentle...
I am trying to develop a page to display student/class results by subject/teacher.
Some classes have groups which contain students and some have only students. A subject is thought by one or more teachers. This may change in the future and I want to keep the design as flexible as pos...
Hi all.
I have a problem using Telerik RadGrid.
When I apply a filter on a data column, I use the filter expression as a Linq expression.
So (server side) I parse it with Dynamic Linq (from MIcrosoft LINQ examples) in NeedDataSource handler.
The problem is that when I specify "Start With" as a filter, I receive the following as "Linq ex...
Is there an exception that I can use for when there are one or more files not found?
I'm doing this: filePaths.Where(file => !file.Exists); and I need to throw some kind of FilesNotFound exception. Do I need to inherit from Exception and make my own exception class?
I'm using C# .NET 4.
...
lets say i have :
anything.where(x=>x.age == int.parse(txtage.text));
now i know that int.parse(txtage.text) is an expression of type ExpressionType.Convert
now i wanna know how to create an expression of type ExpressionType.Convert manually (programatically)
why ?
because im passing expressions between layers and changing the ty...
I am using the LinqToExcel project developed by MIT and hosted on Google Code at http://code.google.com/p/linqtoexcel/wiki/UsingLinqToExcel.
It seems pretty straight forward and elegant. I was able to rewrite a method that used the MS excel interop library and the code was about 1/3 the size.
However, I ran into an issue with trying to...
I have a domain service, derived from LinqToEntitiesDomainService<FOOEntities>
It has one method, IQueryable<Bar> GetBar(). GetBar returns a LINQ query on the entity model. The LINQ works fine in LINQPad.
In the XAML of a Silverlight thingy, I have a ListBox whose ItemsSource points to a DomainDataSource defined in the same XAML file,...
I have an XML like below :-
<SourceXML>
<Issue ID="123">
<Fields>
<Number>5</Number>
</Fields>
</Issue>
<Issue ID="125">
<Fields>
<Number>8</Number>
</Fields>
</Issue>
<Issue ID="127">
<Fields>
<Number>11</Number>
</Fields>
</Issue>
</SourceXML>
I have to get all the Issue nodes which have number as 11 or 8(where clause filter)
I tri...
Which linq query more productive
values.SelectMany(val => val.childs).Where(predicate)
or
values.SelectMany(val => val.childs.Where(predicate))
where val.childs is array Child[]
Thanks
...
Error 4 Cannot implicitly convert type
'System.Collections.Generic.IEnumerable<System.Collections.Generic.IEnumerable<CCE_2009.Data.Person>>'
to
'System.Collections.Generic.IEnumerable<CCE_2009.Data.Person>'
Generated from:
var RecoveryManagerQuery =
from RM in
(
from REP in e.Results
select REP.Organ...
According to NHProf, the use of implicit transactions is discouraged:
http://nhprof.com/Learn/Alerts/DoNotUseImplicitTransactions
However, NHibernate LINQ returns an IQueryable<> when reading objects from the database, and this is lazily evaluated. I have this method in a repository:
public IQueryable<T> GetAll<T>()
{
using (var t...
I have a List, MyStuff has a property of Type Float.
There are objects with property values of 10,20,22,30.
I need to write a query that finds the objects closest to 21, in this case it would find the 20 and 22 object. Then I need to write one that finds the object closes to 21 without going over, and it would return the object with a ...
I had tried to join two table conditionally but it is giving me syntax error. I tried to find solution in the net but i cannot find how to do conditional join with condition. The only other alternative is to get the value first from one table and make a query again.
I just want to confirm if there is any other way to do conditional join...
There are lots of Linq algorithms that only need to do one pass through the input e.g. Select.
Yet all the Linq extension methods sit on IEnumerable rather than IEnumerator
var e = new[] { 1, 2, 3, 4, 5 }.GetEnumerator();
e.Select(x => x * x); // Doesn't work
This means you can't use Linq in any situation where you are rea...