Using The IEnumerable Function Intersect() To Combine A Few List And Get The Similar Integers?

Jun 2, 2010

I would like to use the IEnumerable function Intersect() to combine a few list and get the similar integers from each list. The problem I'm faced with is that I don't know how many list I will need to compare.

Here is an example:

A{1,2,3,4}
B{1,2,3}
C{1,2}

results = A.Intersect(B).Intersect(C)

This works great, but the next time around I may have a D{1,2} next time I come across the function.

I'd like to use the Intersect method, but I'm open to new ideas as well.

View 1 Replies


Similar Messages:

SQL Server :: How To Combine Multiple Rows Into A Comma-delimited List In Sql Server In Build Function

Jan 10, 2011

How can I combine multiple rows into a comma-delimited list in sql server in build function?? in HCL

examples :

X
---
12
15
18
20

Output : 12, 15, 18, 20

with in build function of sql server.

View 6 Replies

How To Find Integers In Multiple List

May 27, 2010

In a vb.net application I have a set of integers currently stored in multiple Arraylist (But this could be something different if required)

al1 = {1, 2, 3, 6, 7, 9}
al2 = {2, 3, 4, 9}
al3 = {2, 3, 19}

I would like to get the set {2, 3}

I thought about using LINQ to join the list, but the number of Arraylist can change. I know I can always loop through everything and check if an integer exsist and keep track of it, but I thought there might be an easier way?

View 3 Replies

Web Forms :: Populating Dropdown List To Show Many Integers

Mar 19, 2010

I want to populate a Dropdown list from divisons of a figure in my projects database

for example database figure 50

I want the dropdown list to show 5,10,15,20,25,30,35,40,45,50

The database figure wont always be the same.

how would i go about doing this ? esp the populating of the dropdown list itself based on the way i want to show it.

View 3 Replies

C# - Best Pratice: How To Implement A List Similar To Stackoverflow's Users List

Apr 7, 2010

Technologies involved:

ASP.NET Web-forms
Javascript (jQuery for instance)

Case,To make it clearer let's give the Stackoverflow Users list as an example. This list can be manipulated at client-side. I can search, page and so forth. So obviously we would need to call jQuery.ajax to retrieve the HTML of each page given a search. Alright. Now this leaves me with the first question:

What is the best way to render the response for the jQuery.ajax at server-side? I can't use templates I suppose, so the most obvious solution I think is to create the HTML tags as server-controls and render them as the result of an ASHX request? Nice. That solved we have yet another problem:

When the user first enters the Authors List the first list page should already come from the server completely rendered alright? Of course we could render the first page as well as an ajax call but I don't think it's better. This time I CAN use templates to render the list but this template couldn't be reused in case 1. What do I do?

Now the final question: Now we have 2 rendering strategies: 1) Client and 2) Server. How do I reuse code for the 2 renderings?

View 2 Replies

How To Convert List Into Ienumerable

May 1, 2010

I am using LINQ for data connectivity and have made class which return me the result set into presentation here is the syntax:-

public List<ClsDermaInvestigation> MthdisplayInvestigation()
{
List<ClsDermaInvestigation> lstinvst = new List<ClsDermaInvestigation>();
ISingleResult<USP_Patient_Dermatology_InvestigationResult> investresult = objderma.USP_Patient_Dermatology_Investigation(PatientID, RepDate, Hb, TLC, F);
foreach(USP_Patient_Dermatology_InvestigationResult rel in investresult)
{
ClsDermaInvestigation objinvest = new ClsDermaInvestigation();
objinvest.Albumin = Convert.ToDouble(rel.Albumin);
objinvest.ALP = rel.ALP;
objinvest.ANA = rel.ANA;
objinvest.Date = rel.date;
lstinvest.add(objinvest)}return lstinvest}
This list is returning me the result.It works fine but in 1 case am using the same list to bind my Date dropdownlist.
//aspx.cs code
List<Dermatology.ClsDermaInvestigation> objlstinvest = objinvest.MthdisplayInvestigation();
//Array s = objlstinvest.to
drpDate.DataSource = s;
drpDate.DataTextField = "Repdate";
drpDate.DataValueField = "Repdate";
drpDate.DataBind();

But it throws an error that list does not conatin a property with "Repdate";. How can i bind this list with dropdownlist?? Can i convert it into some type so that i would be able to bind it??

View 2 Replies

What Is The Difference Between IEnumerable And List

May 18, 2010

I've read some articles about this but for some reason they're just not doing it for me. I'd like to understand the difference between

IEnumerable<string> myList and List<string>myListToo

View 7 Replies

DataSource Controls :: Ienumerable For Dropdown - Loop Through The Values Coming From Function?

Feb 8, 2010

Here is my code, using LinQ to get the data from database.

public IEnumerable categoryData()
{
db = new DBModelDataContext();
var cat = from c in db.Categories
select new { c.categoryname,c.categoryid };
return cat;
}

trying to get the values (categoryname and categoryid) into textfiled and valuefield of dropdown list.

dt = new clsData();
ddlCategory.DataSource = dt.categoryData();

what is the code that i need to write to assign the categoryname to textfield and categoryid to valuefield. I mean how to loop through the values coming from the above function.

ddlCategory.DataBind();

View 2 Replies

SQL Server :: Combine Two Self Referencing Queries In A Function?

Feb 23, 2011

I have a menu table which has a (mostly) unlimited number of levels/tiers:

[Code]....

I also have a working function which will give the up and down tiers based on a given MainMenuId:

[Code]....

My question is, is there a better way to do this such as combining the two querries? Every attempt I have made results in a "The Statement terminated. The maximum recursion 100 has been exhausted before statement completion"

View 4 Replies

IEnumerable - Get The Split String Into OpensReviews List

Sep 24, 2010

I have a string which is stored as a cookie. The string is made up of the following data:

int userId
DateTime expiryDate

A user can have a number of these, so I store them like this "userId,expiryDate$userId,expiryDate"

When I retrieve the cookie value, I then split the string and add it to a list. The list is List<OpenReviews> openReviews, which contains the two variables above. I use the following piece of code to split the string:

string[][] reviews = value.Split( '$' ).Select( f => f.Split( ',' ) ).ToArray();

As you can see it goes to an array which I then have to iterate through to add it back into my list. All of which seems extremely long winded. I believe I can use the code above to put it into an IEnumerable<IEnumerable<string>> format. The problem is I don't know how to then get it into my List<OpenReviews> I'm therefore looking at getting the split string into my OpensReviews list as efficiently as possible.

View 2 Replies

Combine Alert Popup In Save As File Function In C#?

Jul 17, 2010

I'm tring to write a function that need to save a file (in csv) and has a condition.

it's something like that:

If the file is small then 1MB then I want to pop up an alert in javascript and then continue with the save as file commands.

What I did was:

if(...)
{
}
else
{
ClientScript.RegisterStartupScriptBlock(...alert('aaa')...);
}
Response.ContentType = "text/csv";
Response.AppendHeader("Content-Disposition","attachment; filename=file.csv");
Response.TransmitFile("FILE.csv");
Response.End();

the save as works fine. but the alert wont popup in the else case. I tried RegisterStartupScript. I tried many options. But it seems that the response.end is stops the clientscript from happening.

I am writing in c# asp.net (ajax enabled website, but not in use), visual studio 2005.

View 1 Replies

C# - List Manager Applications For .net Mvc That Are Similar To Sharewpoint?

Mar 24, 2011

Are there any "list" manager applications for asp.net mvc (or vanilla asp.net) that are similar to say:Sharepoint ListsCreate your own list on google sites would prefer open-source!

View 2 Replies

Forms Data Controls :: How To Combine Some List Items Together

Jan 8, 2011

just want to have a quick question about the value of dropdownlist listitem. I have a gridview which has its datakey value linked to a dropdownlist. In the dropdownlist I have many listitems. So I decided to combine some list items together. Originally, the values of the items are 1,2,3,4,5,6,7,8. But I want to have only 5 items by combining 5,6,7,8 into one listitem called "Others." So if the listitem "Others" is selected, the gridview will show all the records that have value 5 or 6 or 7 or 8. Is it possible? How can that be done?

I hope I made myself clear. Any question, I am happy to clarify.

View 4 Replies

AJAX :: Async Loading Of List - Similar To Facebook And Twitter?

Mar 2, 2011

I tried to search around, but could not find anything for this question which must be wrong, because I would guess there were a lot of topics about it.

Anyway, I would like to load lists on my site in a similar style to Facebook and Twitter, where initially x records are loaded into the list, and then after the page has loaded the list expands downwards with more rows of content, or add a "more" button in the end. I am using ASP.NET with C#.

View 1 Replies

C# - Iqueryable Intersect Fails When Applied Twice?

Feb 11, 2011

I have a series of parameters stored in rows in the database, and I'd like to return rows that satisfy both input parameters. The parameters come through in the URL, like "&msg_type=20560&status=101"

I have code that works fine, but only if there's one parameter. If there are two, it empties out the results. Here's my code:

[code]....

View 1 Replies

C# - All Queries Combined Using A UNION, INTERSECT Operator Must Have An Equal Number?

Jan 7, 2010

I have a linq to sql query where I have to perform union two set of records.

And I do not have equal number of fields, so added the null

eg my psuedo code is

[code]....

after googling some hours I came to understand that it is bug in 3.5 framework.

Now I want to retrieve the result.

How do I do thatI tried framing into two seperate iqueryable

var a= first query

var b =second query

ilist result =a.union b

This too results in the same error.

View 3 Replies

MVC :: DataAnnotation Attribute For Integers?

Jan 11, 2011

Is there an out-of-the-box DataAnnotation attribute that checks if an integer is greater than a certain value?

public Model
{
[GreaterThan(0)]
public int MyVal{get;set;}

}

View 4 Replies

Web Forms :: Counting Fields As Integers

Oct 30, 2013

I have 4 drop down menus labeled as with static input as

0-9; JobPerReview1 JobPerReview2 JobPerReview3 JobPerReview4

If for choice the user selects the following;

JobPerReview1 = 3JobPerReview2 = 0JobPerReview3 = 5JobPerReview4 = 9

I would like a function/ script to sum the total inputs as an integer or if that's the correct term for it. So it would calculate something like thisJob

PerReview1 = 3 summed as 1JobPerReview2 = 0 summed as noneJobPerReview3 = 5 summed as 1JobPerReview4 = 9 summed as 1

I would also like a total box labeled "NOF (number of factors)to calculate the selections such as;

NOF = 3

This is starting to be mind bugling function

getItems(){var items = new Array();var itemCount = document.getElementsByClassName("items");
var total = 0;var id= '';for(var i = 0; i < itemCount.length; i++){id = "p"+(i+1);total = total + parseInt(document.getElementById(id).value);
} document.getElementById('tot').value = total;return total;
} getItems();
function getItems() {
var items = new Array();

[Code]....

View 1 Replies

Web Forms :: Validation - Accept Only Integers And Decimals?

Mar 25, 2010

I have A textbox inside formview, ive add litered textbox from ajax and allow only numbers and "."Works fine. THe only problem they can enter multiple dots. I want textbox to accept only following formats: 100, 1234.56 - i.e integers and decimals.

View 2 Replies

SQL Server :: Bulk Insert Errors With Integers And Csv?

Feb 24, 2011

I'm trying to import csv file that that uses double qoutes from the text qualifer but doesn't use any qualifiers for the numbers or null fields. The data looks like this:

1,"Jack","Smith",23,
2,"Susan","Smith",,
3,"Mike","Smith",,
2,"Chris","Smith", 18,

The command I'm using is:

[Code]....

I keep getting "Bulk load data conversion error (type mismatch or invalid character for the specified codepage)" when it tries to insert null from the csv into a numeric data type.

I tried changing the codepage, datafiletype, fieldterminator, formatfile but I still can't get it to work.

View 3 Replies

DataSource Controls :: Use WHERE In With Comma-separated String Of Integers?

Feb 7, 2011

Been Googling about this for a couple of hours but haven't hit on the solution yet. This is an ASP.NET 3.5 app connecting to an MS SQL 2008 backend. The app uses a strongly typed dataset with ad hoc queries in table adapters. The object data source on the markup page will have one parameter that will accept a string of comma separated IDs. I need to feed that list of IDs to the WHERE clause in a query to pull each of the specified records. This is trimmed down version of the query:

[Code]....

View 2 Replies

C# - How To Sort The Grid View Whose Column Is Listing Integers

Feb 17, 2011

I am sorting the grid using DataView's "Sort" property. I am passing sort expression and the order in which the grid is to be sorted(ASC or DESC). But the problem is, since the column on which I am sorting the grid is listing the intergers, the sorting is happening as if it is a string. But I need integer sorting rather string sorting on that column.

The grid displays below as ascending order(string sorting)
55
77
8

But I need the columns to be displayed like this(Integer sorting)
8
55
77

View 2 Replies

Crystal Reports :: Displaying Integers For Running Total Result?

Mar 5, 2011

I've got a report w/ grouping and a running total field. The running total is the sum of 'n' integer values, however, when I display the running total field it displays a floating point value. So for example, two rows have 10 and 15, but the the running total displays 25.00. Is there a way to display this result as an integer? I tried using a formula field w/ the 'Int', 'Truncate', and 'Round' functions, but nothing seems to work.

View 2 Replies

Generic List - Remove Function Not Working

Feb 9, 2010

I have a generic list which contains a class called Parameter. Parameter contains 2 integers, ParamType and ParamValue. A generic list is built containing a small number of values List<Parameter> myList I have created a function which passes in 2 parameters. These are passed individually but are used to create a new Parameter within the function. The Parameter is tested against myList, and if it is found removed. In order to do this I have used the remove function, the syntax being:

myList.Remove(new Parameter(ParamType, ParamValue));

The remove isn't working and at present I'm using LINQ to do it.

View 2 Replies

Return Generic.List<Anonymoustype> From A Function In C#?

Dec 10, 2010

ASP.NET 3.5 C# I am joining two tables using Linq. Table names are MapAssets and ExitPoint. In Database they are related with 'has a relationship'

I am writing a function in my BLL to return the joined table

public List<ExitPoints> GetExitPointDetailsByProjectID(int iProjectID)
{
ctx = new CoreDBDataContext();
var exitPointDetails = from ma in ctx.MapAssets
join ep in ctx.ExitPoints
on ma.MapAssetID equals ep.MapAssetID
where ma.ProjectID == iProjectID
select new
{
//would like to have data from both tables here
ctx.MapAssets,
ctx.ExitPoints
};
return exitPointDetails.ToList();
}

This obviuosly doesn't work. And I dont know what to return at all. All constraint I have for the return is to be able to be bound to a gridview. is this the correct way? Or else whats the correct way?

View 6 Replies







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