linq

any log about db queries executed in my site?

Hi, I own this site: www.gramma.ro. (asp.net/c#)... I've been working 2 days on doing improvements on UI using YSlow and PageSpeed. Well...at this moment the site seems to load ok...i mean from the UI point of view. (Page Speed improvments from 51 to 75; YSlow from F to D(C) ). BUT there is still "waiting" time between pressing a link...

How to select Values from several tables

my three table structure are : USE [DB_OrderV2] GO /****** Object: Table [dbo].[tblPageInfo] Script Date: 07/24/2010 23:16:18 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[tblPageInfo]( [Code] [int] IDENTITY(1,1) NOT NULL, [PageID] [smallint] NOT NULL, [PageName] [nvarchar](80) NOT NULL,...

Grouping data with a LINQ query

Hello, I have a C# DataTable with 5 columns in it. I only care about two of the columns in the DataTable. The two columns I care about are called "CreateDate" and "ID". They are a DateTime and string. The DateTime represents the date on which a ticket was submitted. The ID uniquely represents a ticket. I am trying to write a LINQ statem...

Starts with doesn't work in Linq to NHibernate query

In my repository I have: public IQueryable<ICustomer> GetByAddress(string address) { return from c in GetSession().Linq<ICustomer>() where c.Address.StartsWith(address) select c; } The SQL I'd like it to generate is essentially: SELECT * FROM Customer WHERE address LIKE @address + '%' However, whenever I d...

Is there any elegant way in LINQ to bucket a collection into a set of lists based on a property

i have a collection of cars. I want to bucket this into separate lists by a property of the car . . .lets say brand. So if i have a collection of some Ford, some Chevy, some BMW, etc, i want a seperate list for each of those buckets. something like: IEnumberable<Car> myCarCollection = GetCollection(); List<IEnumerable<Car>> buckets ...

IEnumerable<T>.Contains with predicate

I need just to clarify that given collection contains an element. I can do that via collection.Count(foo => foo.Bar == "Bar") > 0) but it will do the unnecessary job - iterate the whole collection while I need to stop on the first occurrence. But I want to try to use Contains() with a predicate, e.g. foo => foo.Bar == "Bar". Currentl...

Combine lists of key value pairs where keys match

I have a list of List<KeyvaluePair<DateTime, int>>, which I want to merge into one (union), and where there are pairs with the same key in more than one list, have their values summed. Example: input list 1: date1, 1 date2, 2 input list 2: date2, 3 date3, 4 input list 3: date3, 5 date4, 6 desired output: date1, 1 date2, 5 date3, 9 d...

How to Update previous row column based on the current row column data using LinQ

var customer= from cust in customerData select new Customer { CustomerID = cust["id"], Name = cust["Name"], LastVisit = cust["visit"], PurchashedAmount = cust["amount"], Tagged = cust["tagged"] Code = cust["c...

Linq dbml show int return type for an SP which SP return some fields from temporary table.

I have written a Stored procedure which return some fields from a temporary table which i create in this stored procedure. but when I include it in my dbml file it show return type of my stored procedure as int. which should be not as am returning field from table although its temporary. ...

What's problem on linq databinding

<dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False" KeyFieldName="CategoryID"> <SettingsEditing Mode="Inline" /> <Columns> <dx:GridViewCommandColumn VisibleIndex="0"> <EditButton Visible="True"></EditButton> <NewButton Visible="True"></NewButton> <DeleteButton...

How to avoid OrderBy - memory usage problems

Let's assume we have a large list of points List<Point> pointList (already stored in memory) where each Point contains X, Y, and Z coordinate. Now, I would like to select for example N% of points with biggest Z-values of all points stored in pointList. Right now I'm doing it like that: N = 0.05; // selecting only 5% of points double cu...

LINQ select new class with a name

I have a linq query where I am creating several classes which have a Parent property on them. I am looking for a way to set the parent property to be the class I just created. My explanation sucks; here's code of what I'm trying to do. var query = from states in xml.Elements() select new State {...

How to browse through the deserialized object

Hello, I'm receiving deserialized object using WCF (trying to get latitude and longitude using google api) however after that I need to get inside that object I received and obtain values for two properties which I'm interested in: public double Lat { get; set; } public double Lng { get; set; } Those are nested inside the object. Her...

How can you retrieve all records of certain subtype dynamically with Linq to Entities?

I am trying to get a list of all objects in the database of a specified type. I have done this before when the type was known at compile time, but now I am trying to pass a type into the method and have the method return all the records of that specified type, and I can't get it working. I have tried the following: public IList<W...

Can you create a grouping based on ranges?

This is related to Another Question, which I think really gets at a much simpler problem so I'm asking the simpler question here in the hopes it will help me solve the more complex one. I would like to be able to create a grouping in a linq to sql query that groups based on a range of data within another set of data. However, i think i...

query that gets only the records needed to the page using Linq

i want to use Linq's Iquerable that gives me the ' query that gets only the records needed to the page' based on the Page size i have given. i have used this: System.Linq.IQueryable<DataTable> ds = (from m in dttableDetails.TableName select m).Take(page_size).Skip(offset); but it is showing me error. i need the returned type as ...

Entity Framework LINQ - Subquery with Group By

Hi guys, I am trying to achieve a query which includes a subquery which itself includes grouping. I based my code from answers to this question The purpose of the code is to perform a simple de-duplication of the 'person' table based on the email address and return the latest person row. var innerQuery = (from p in db.Person ...

query that gets only the records needed to the page using Linq- not fetched the record based on page size

i have used this query to fetch the Record of the Datatable based on the Pagesize. IEnumerable<DataRow> query1 = from row in dt.AsEnumerable().Take(page_size).Skip(offset) select row; Datatable boundTable= query1.CopyToDataTable(); first time when it opens the offset will be =0; it gives 10 records, next time i pass the offset a...

Can you lazy load when model has associations, but the database does not?

Hi, I am working on an old database, that i do not want to touch or modify in any way if possible. I want to build a new application that uses it's data but the database has no actual relations despite having primary and foreign keys linking tables. If i import these tables into an Entity Framework model and add the associations manual...

RavenDB: How to do a simple map/reduce aggregation

Ok given a collection of documents like this: { "Name": "A", "Price": 1.50 } How do I perform a simple aggregation on the prices in the list? I don't want to perform any grouping, just a simple scalar result. ie. sum, avg etc I have tried both of the following without success: Map only: for doc in docs select new { sumPrices ...