LINQ Query - Collapse Two Rows Into One

Nov 26, 2013

Using a LINQ query and an aspx page with an Infragistics webdatagrid control, I am generating data that look like this:The data come from my dataset: There is another column which is TobaccoUse and it is N, Y, N, Y, N, Y, etc for each row. There is also a column for the rate, and it is 147.32 for all rows (test data). But it could and most likely will, especially as the ages increase, be different, like $250 for a 25-year-old smoker but $200 for a 25-year-old non-smoker.

The grid I want to present needs to collapse every two rows into one, so you see one row for 0-17 smoker and non-smoker, etc. I do not know how to write this query. I don't actually know how to write any LINQ query but I've enhanced some existing ones, or understood them, but it's easier to read something that exists than write it new or change it dramatically, which I believe I need to do.

The query right now is:

Code:
var medRateBook = from rates in dsMedRateBookRates.Tables[0].Rows.Cast<DataRow>()
select new
{
DivisionNum = div.DivisionNbr.Trim(),
Age = rates["agedesc"].ToString().Trim(),
TobaccoRate = rates["calcratePreferred"].ToString().Trim(),

[code]....

View 2 Replies


Similar Messages:

DataSource Controls :: Top 10 Rows As Well As Count Of All Rows From Linq To Sql Query

Jun 17, 2010

[Code]....

In above query I want to have top 10 rows as well as count of all rows.

View 3 Replies

Forms Data Controls :: Expand And Collapse Grid Rows + Check Box For Selecting Rows?

Mar 21, 2011

I have been handling everything in code which is not working consistently same in all scenarios.

View 1 Replies

DataSource Controls :: LINQ Query To Grab The Last 5 Rows From A Group?

Jan 8, 2010

i have the following objects:

Event:

- EventID (PK)
- GroupID (FK)
- StartDate

Group:

- GroupID (PK)
- GroupName

What i need to do is select the last 5 events for each group using LINQ to Objects. I tried starting with:

[Code]....

But i'm not sure how i only take the last 5 per group.

The simple way of doing this is to get the groups and then have a property on that which returns the last 5 events but if i databind this i will have to use a nested Repeater/ListView. Ideally i would like to have a row foreach event.

View 3 Replies

Web Forms :: Expand And Collapse Rows Of A Table?

Jul 20, 2010

I am creating an ASP.NET web Appivation in which I have added many rows in the table.

When I run the application the table is not displayed, only the rows are displayed.

My question is I want to Expand and collapse the rows since they are large in no.

View 4 Replies

Forms Data Controls :: Sql To Linq Query / Looking To Translate An SQL Query Into Linq?

May 28, 2010

I'm looking to translate an SQL query into linq

INNER JOIN Usrs ON
SAQ.UserId =
Usrs.UserId AND Scan.UserId =
Users.UserId

I'm not sure how to include the "AND" in the LINQ statement.

View 3 Replies

Forms Data Controls :: Collapse And Expand Rows In Grid?

Jan 25, 2011

I want to populate the search results in grid. The results should be grouped based on condition. I mean if i am searching for name called Osama laden, all the names containing Osama be grouped(+) and Laden as well. I should get the count side to the (+) button. When i click on + button the results should expand and when i click on(-) the results should collapse.

View 2 Replies

Forms Data Controls :: How To Have A Expand/collapse All Function On Top Of Individual Rows

Jul 6, 2010

I have this function to expand and collapse rows in gridview from this website:

[URL]

how to have a expand/collapse ALL function on top of individual rows?

View 6 Replies

Forms Data Controls :: Expand And Collapse Rows (With + ) In Gridview For Same Data In A Columns

Feb 3, 2011

How can I Expand and Collapse the rows in gridview for a column having same row data.

View 2 Replies

ADO.NET :: Dynamic LINQ Query / Use "if Statement" In Linq Query

Feb 11, 2011

I want to use "if statement" in Linq query. How can I do this situation?

For example:

if txtAge.Text=="", I will not use that in Linq Query.

else txtAge.Text!="", I will use that in Linq Query.

View 8 Replies

ADO.NET :: Build A Linq Query / Linq Random Selection?

Sep 14, 2010

I've build a linq query.But i want a random selection so its not always ID : 1,2,3,4,5,6 How can i randomize this var? I like to bind it to a repeater.//TagCloud:

Random rand = new Random();
var tc1 = from i in JumpTide.cms.menu.GetMenuItems(32)
select new

[code]...

View 1 Replies

DataSource Controls :: How To Convert Sql Query Into Linq Query

Mar 10, 2010

select Groupid,GroupName,onorusername from palgroup where groupid in (select distinct Groupid

View 5 Replies

Linq Query Returning Less Records Than Sql Query?

Mar 19, 2011

I am facing a big problem with simple linq query.. I am using EF 4.0..

I am trying to take all the records from a table using a linq query:

var result = context.tablename.select(x=>x);

This results in less rows than the normal sql query which is select * from tablename;

This table has more than 5 tables as child objects (foreign key relations: one to one and one to many etc)..

This result variable after executing that linq statement returns records with all child object values without doing a include statement.. I don't know is it a default behavior of EF 4.0 . I tried this statement in linqpad also..but there is no use... But interesting thing is if I do a join on the same table with another one table is working same is sql inner join and count is same..but I don't know why is it acting differently with that table only.. Is it doing inner joins with all child tables before returning the all records of that parent table?

View 2 Replies

Linq Query - How To Select Inner Query Into List

Oct 17, 2010

I am writing a linq query to select a blogpost,

[code]....

The blogpost i am testing got 3 tags attached to it. The table structure is:

(table)BlogPost -> (table)BlogPostTags <- (table)Tags

So the BlogPostTags table only contains 2 fields, BlogPostID and TagID.

When i run the query above i get 3 results back. Same blogpost 3 times but with 1 tag in each. It should return 1 post with 3 tags. The problem lies in the Tags query above.

View 1 Replies

SQL Server :: Get All Rows From Query A That Are Not In Query B?

Dec 17, 2010

Using sql server 2005.

I have an Query A of fields that returns X number of records.

I create a Query B of same fields that returns X-80 number of records.

I want to find out the 80 records that are in Query A but are not in Query B. what is the syntax for this?

View 4 Replies

ADO.NET :: LINQ Entity Framework Query - Construct "nested" Query?

Jan 22, 2011

I have a web app for our golf club. When I compute handicap index for each golfer, I have to select the most recent scores and then a subset of those scores depending on how many rounds of golf the golfer has played. All the scores are entered into a single SQL Express table called "Rounds". Verbally, this is what I'm trying to do:

1) select the twenty most recent golf scores (sort on date descending, "take(20)") [if less than 20 records, then select all available];

2) for this set of records, select the 10 lowest scores (or smaller number if golfer has less than 20 rounds);

3) compute the average round differential for the subset of records, etc. to calculate handicap index (this step is working ok...)

My current VB code has this LINQ query (which is flawed -- it selects the lowest handicap differential scores of ALL records for the filtered user):

[Code]....

How do I modify this query to accomplish items 1) & 2) above? It seems this should be simple, but my experience with queries is still limited.

View 2 Replies

Return Next 5 Rows Using LINQ In C# .NET

Aug 20, 2010

I'm using LINQ to query my database, and I don't want all the records returned all at once. Instead, user should be able to select Next 5 and Previous 5 using buttons. As of this moment I have selected the first 5 rows in the Item table in the databas like this:

private void ShowItems()
{
var items = (from p in db.Items
orderby p.ID descending
select new { ID = p.ID, Item = p.itemName,
Qty = p.quantity }).Take(5);
[code]...

View 3 Replies

ADO.NET :: Linq To SQL Rows Dependancies?

Mar 27, 2011

I'm using a SQL table for processing "batch" actions. However, each action depends on the success of a previous action. So, when I set up my actions in my Action table, each SQL row needs to have an ID that is linked back to the previous row that is created. How can I do this in Linq? Is there a better approach to handling dependancies in SQL?

View 3 Replies

ADO.NET :: Append New Rows To Gridview With LINQ?

Oct 22, 2010

i get a string value from the user and search the database to display the relevent information in the gridview. i should be able to do this iteratively and the output should be appneded at the end of the gridveiw. is it possible in any way?

[Code]....

View 2 Replies

ADO.NET :: How To Check If The Tables Has Rows In Linq

Nov 23, 2010

I am very new to Linq , i want to check if the PrintingAdminSetting table has rows in it and then if it has then i want to get the value and assign it to txtMaxJobs textbox

below is teh code

, please let me know teh syntax to check .

var DC = new ServiceDataContext();
var rec = DC.PrintingAdminSetting.Where("").First();
txtMaxJobs.Text = rec.ParaName.ToString();

View 4 Replies

ADO.NET :: Delete Duplicate Rows Using Linq?

Dec 14, 2010

I have a datatable in which some of the rows contain a column with duplicate values. I need to be able to delete the duplicate rows and leave only one, doesn't matter which one.

The rows might look like this:

A, B, C, D
E, F, G, D
H, I, J, D

I need to delete two rows and be left with only one.

View 6 Replies

ADO.NET :: LINQ To Entity Multiple Rows WCF?

Dec 15, 2010

I am selecting some products from database and would like to show them in client's grid using WCF. Problem is I don't know how to pass selected collection to the client since my method can't return that data type.

My method:

public class Service1 : IService1
{
public ProductData GetData(int value)
{
using( NorthwindEntities NWEntities = new NorthwindEntities()){

[Code]....

View 2 Replies

ADO.NET :: LINQ To Entities - Getting The Value Of The Rows By Column?

Nov 17, 2010

All I am trying to do is query the database, then get the returned values, so that I can do some calculations. But, I don't understand how to get the values from the database row that is returned, so that I can assign it for usage.

I would like to do something where the logic goes: for the index of [1] (which is just column 1), multiply it by 2. For the index of [2] (which is just column 2), multiply it by 3.

Example below:

This does NOT work:

[Code]....

View 6 Replies

ADO.NET :: Update A Column For All Rows In A Collection Using Linq?

Jul 28, 2010

is there a way to update a column for all rows in a collection using linq like sql does it

eg. UPDATE myTable SET myColumn='newValue'

Also weighing options as to whether there is better performance using linq to sql for this or straight sql to DB via table adapters etc.

View 2 Replies

ADO.NET :: Get Number Of Rows Affected By Using Procedure In Linq?

Dec 18, 2010

i have create the object of

1 dataclassContext obj=new dataclassContext();

2 now i call the updateProc

int row=ob.MyupdateProc(QuestionID,peronID);
if(row>0)
{
do some thing
}

but row always retrun 0 even procdure do update in database

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved