Actually i have a little brain bender and and just can't find the right direction to get it to work:
Given is an IList<IDictionary<string, double>> and it is filled as followed:
Name|Value
----+-----
"x" | 3.8
"y" | 4.2
"z" | 1.5
----+-----
"x" | 7.2
"y" | 2.9
"z" | 1.3
----+-----
... | ...
To fill this up with some random data i use...
Hi folks, I'm trying to filter a set of records based on a sub-object's criteria. This compiles ok
recordList = recordList.Where(r => r.Areas.Where(a => a.Area == "Z").Count() > 0);
but this doesn't
recordList = recordList.Where(r => r.Areas.Where(a => a.Area <= "Z").Count() > 0);
giving these errors
Cannot convert lambda expressi...
I am new one with Linq and I would like to modify my old c# code to use Linq.
The idea of this code to select all tables where it's not set and reference’s field PrimaryTable equal "myTable"
foreach (Table table in dbServer.Tables)
{
if (!table.IsSet)
{
foreach (Reference...
Hello,
a quick question which may or may not be easily answered.
Currently, in order to return a limited result set of data to my calling reference using SubSonic I use a similar function as below:
_DataSet = from CatSet in t2_aspnet_shopping_item_category.All()
join CatProdAssignedLink in t2_aspnet_shopping_li...
I just finished using Linq to Sql to map our existing Database structure for use in a Thick Client app.
While writing some Linq Methods to replace some Stored Procedures I noticed that sometimes I could do tblOne.tblTwo.MyDesiredField. I learned that there needed to be an association in the dbml for that to work. Well mine was missi...
I have the following LINQ that is causing my obfuscator to break.
.Where(f => f.FileName == fileName).OrderByDescending(f => f.Position).FirstOrDefault();
Is there another way I could reword this LINQ statement to test against my obfuscator?
I've reported the bug, but it could take 1-2 months to fix, so I need to try recode this LIN...
I try to write a LINQ statement which returns me all possible combinations of numbers (I need this for a test and I was inspired by this article of Eric Lippert). The method's prototype I call looks like:
IEnumerable<Collection<int>> AllSequences( int start, int end, int size );
The rules are:
all returned collections have a length ...
I'm a .NET web developer primarily who occasionally writes console applications to mine data, cleanup tasks, etc. Most of what I do winds up involving a database which I currently design via sql server management studio, using stored procedures, and query analyzer. I also create a lot of web services which are consumed via AJAX applica...
So, this question was just asked on SO:
http://stackoverflow.com/questions/2740001/how-to-handle-an-infinite-ienumerable
My sample code:
public static void Main(string[] args)
{
foreach (var item in Numbers().Take(10))
Console.WriteLine(item);
Console.ReadKey();
}
public static IEnumerable<int> Numbers()
{
int x =...
I have a linq query that is causing some timeout issues. Basically, I have a query that is returning the top 100 results from a table that has approximately 500,000 records.
Here is the query:
using (var dc = CreateContext())
{
var accounts = string.IsNullOrEmpty(searchText)
? dc.Genealog...
I'm trying to write a LINQ query and am having problems. I'm not sure if lambda expressions are the answer or not but I think they may be.
I have two combo boxes on my form: "State" and "Color".
I want to select Widgets from my database based on the values of these two dropdowns.
My widgets can be in one of the following states: Not S...
Dim db As New SQLDataContext
Try
Dim deleteBoatPics = (From boat In db.Photos
Where boat.boatid = id)
db.Photos.DeleteOnSubmit(deleteBoatPics)
db.SubmitChanges()
Catch ex As Exception
End Try
I'm getting an error that says:
Unable to cast object of type 'System.Data.Linq.DataQuery`1[WhiteWaterPhoto...
I'm having problems when using linq on a datatable.asenumerable().
This throws InvalidCastException.
DateTime date=r.Field<DateTime>("date");
This works fine.
DateTime date = DateTime.Parse(r.Field<string>("date"));
What am I missing?
Regards Sven
...
I need to convert some SQL statement to LINQ. How convert LEFT OUTER JOIN to equivalent LINQ statement?
...
Hi,
The following code is generating a runtime error and I have no idea why.
from o in Orders
group o by o.Employee into employeeOrders
select new {
employeeOrders.Key.EmployeeID,
employeeOrders.Key.FirstName,
Orders =
from eord in employeeOrders
orderby eord.OrderID
select new {
eord.Or...
Hi again,
When trying to do a query using LINQ in VB.net in order to select some employees of a datatable previously filled with a dataset I have a problem when using where clause. What I want is select all the employees of the datatable except those that appear in a list of excluded employees named CurrentExcludedEmployeesLst. So I fol...
Hello!
I have a table (sql server). One of its columns ('Name') Contains Cyrillic values.
From parameters i recieve value, that contains in this fields but the are transliterated.
i mean something like: 'Вася' -> 'Vasya'. And i need to transliterate value field first;
var q = from r in m_DataContext.Table where CTransliteration.Trans...
Using link what is the easiest way to convert a list of longs to a list of ints?
I need it to be a list, if it cant be possibly i would like to see a solution with a int array or some kind f int container.
...
I have the following Transact SQL query using a union.
I need some pointers as to how this would look in LINQ i.e some examples
wouldbe nice or if anyone can recommend a good tutorial on UNIONS in linq.
select top 10 Barcode, sum(ItemDiscountUnion.AmountTaken) from
(SELECT d.Barcode,SUM(AmountTaken) AmountTaken
FROM [Aggregation].[dbo...
(I've put "...to Entities" in brackets since I don't know if this matters at all. I guess this is a quite general LINQ related question.)
I want to check with LINQ (to Entities) if an object exists in the database. At the moment I am doing the following:
using (MyEntitiesContext aCtx = new MyEntitiesContext())
{
var aQuery = from c...