Hi Everyone,
Hi have an issue with Linq. I have an array of double values with duplicate entries. I want to extract only distinct values from it. I have the following code which doesn't work correctly.
double[] dIds = GetIds(); //dIds has more than 10,000 items
var itemIdCollection = from id in dIds.Distinct()
selec...
Hi I would like to take a list collection and generate a single csv line. So take this;
List<string> MakeStrings()
{
List<string> results = new List<string>();
results.add("Bob");
results.add("Nancy");
results.add("Joe");
results.add("Jack");
}
string ContactStringsTogether(List<string> parts)
{
StringBu...
Hello,
I am integrating SqlCacheDependency to use in my LinqToSQL datacontext.
I am using an extension class for Linq querys found here - http://code.msdn.microsoft.com/linqtosqlcache
I have wired up the code and when I open the page I get this exception -
"The SQL Server Service Broker for the current database is not enabled, and a...
Hi. I have set up this programming exercise.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class DataObject {
public int ID { get; set; }
public int ParentID { get; set; }
public string Data { get; set; }
public DataObject(int id, ...
I have a simple Linq to Enities table to query and get the most recent records using Date field
So I tried this code:
IQueryable<Alert> alerts = GetAlerts();
IQueryable<Alert> latestAlerts =
from a in alerts
group a by a.UpdateDateTime into g
select g.OrderBy(a => a.Identifier).First();
Error:
NotSupportedException: ...
How can I order the results from "group ... by... into..." statement in linq?
For instance:
var queryResult = from records in container.tableWhatever
where records.Time >= DateTime.Today
group records by tableWhatever.tableHeader.UserId into userRecords
select new { UserID = userRec...
I am trying to parse an expression tree for a linq provider and running into a little snag with booleans.
I can parse this no problems.
var p = products.Where(x=>x.IsAvailable == true).ToList();
however when its written like this?
var p = products.Where(x=>x.IsAvailable).ToList();
i only get a MemberAccess to look at and i can't s...
I have three string arrays. I want to combine them using zip in linq. How to do?
arr1.Zip(arr2, (a1, a2) => a1 + a2);
How to add arr3?
...
Judging from the result of my last inquiry, I need to calculate and preset the widths of a set of columns in a table that is being made into an Excel file. Unfortunately, the string data is stored in a row-based format, but the widths must be calculated in a column-based format. The data for the spreadsheets are generated from the follow...
Hello,
I use LINQ queries in my ASP.NET MVC application and want to use OutputCache in some of my Actions.
I hear this should be possible with CommandNotifications. But those seem to only go for self-created SQLCommands, or am I wrong?
Can I manually tell SQL server to send SQLDependency notifications if certain tables change? And if...
This is probably a basic LINQ question. I have need to select one object and if it is null select another. I'm using linq to objects in the following way, that I know can be done quicker, better, cleaner...
public Attrib DetermineAttribution(Data data)
{
var one = from c in data.actions
where ...
Hello,
I have several huge sorted enumerable sequences that I want to merge. Theses lists are manipulated as IEnumerable but are already sorted. Since input lists are sorted, it should be possible to merge them in one trip, without re-sorting anything.
I would like to keep the defered execution behavior.
I tried to write a naive algor...
I have 2 tables, Forums and Posts.
I want to retrieve all Forums fields with a new extra field: count all post that belong to this forum.
I have this for now:
var v =(from forum in Forums
join post in Posts on forum.ForumID equals post.Forum.ForumID
select new
{
forum, //Need to retrieve all fields/columns from fo...
I've written some really nice, funky libraries for use in LinqToSql. (Some day when I have time to think about it I might make it open source... :) )
Anyway, I'm not sure if this is related to my libraries or not, but I've discovered that when I have a large number of changed objects in one transaction, and then call DataContext.GetCha...
Hello,
I'm having trouble with a query written in Linq and Lambda. So far, I'm getting a lot of errors here's my code:
int id = 1;
var query = database.Posts.Join(database.Post_Metas,
post => database.Posts.Where(x => x.ID == id),
meta => database.Post_Metas.Where(x => x....
I have the following xml fragment:
<BANNER ID="Banner 2" ROW_WIDTH="200">
<BANNER_TEXTS ID="BANNER_TEXTS">
<BANNER_TEXT UNDERLINE="false" SPAN_COL="1" WIDTHT="78px"></BANNER_TEXT>
<BANNER_TEXT UNDERLINE="true" SPAN_COL="3" WIDTHT="234px">Years In Practice</BANNER_TEXT>
<BANNER_TEXT UNDERLINE="true" SPAN_COL="3" WIDTHT...
I'm trying to use Linq to SQL to return an IQueryable(of Project) when using foreign key relationships. Using the below schema, I want to be able to pass in a UserId and get all the projects created for the company the user is associated with.
DB tables:
Projects
Projid
ProjCreator FK (UserId from UserInfo table)
Companyid FK (Co...
I am implementing some math algorithms based on lists of points, like Distance, Area, Centroid, etc. Just like in this post: http://stackoverflow.com/questions/2227828/find-the-distance-required-to-navigate-a-list-of-points-using-linq
That post describes how to calculate the total distance of a sequence of points (taken in order) by es...
Here's the query in question
return _projectDetail.ExpenditureDetails
.Where(detail => detail.ProgramFund == _programFund
&& detail.Expenditure.User == _creditCardHolder)
.Sum(detail => detail.ExpenditureAmounts.FirstOrDefault(
amount => amount.isCurrent && !amount.requiresAudit)
.CommittedMonthlyRecord.Proj...
I have a data model on LINQ in my project wich i generated from a DB on SQL Server the problem is that all the changes that i make only have effect in the Local DB on my project but not in the web SQL server, how can i replicate the changes automatically?
...