Create New Distinct List(of T) From Existing List(of T) Using LINQ?
Mar 12, 2010
How can I get a new distinct list from an existing list using LINQ? This is what I have so far and it is not distinct but does give me a new list.
Dim tmpQryColumn = (From a In _allAudits
Select New CheckBoxListItem
With {.Id = a.AuditColumn, .Name = a.AuditColumn}
[code]......
View 2 Replies
ADVERTISEMENT
Jun 1, 2011
How can I get a new distinct list from an existing list using LINQ? This is what I have so far and it is not distinct but does give me a new list.
Dim tmpQryColumn = (From a In _allAudits
Select New CheckBoxListItem
With {.Id = a.AuditColumn, .Name = a.AuditColumn}
).Distinct()
_columnList = New List(Of CheckBoxListItem)(tmpQryColumn)
View 2 Replies
Mar 10, 2012
I have a List(Of Hardware) - the List is called HWModels
Class Hardware has the following Properties:
ModelName
Status
CPUStatus
MemoryStatus
DiskStatus
The List is populated by reading a CSV file, once it's populated, I want to return the distinct records based on the ModelName
I've attempted by doing it as follows:
(From a In HWModels Select a.ModelName).Distinct
But this isn't right because I end up with a list of only the ModelName's and nothing else.
How do I get the Distinct function to return all of the other class members within the list?
View 1 Replies
Nov 23, 2011
I'm trying to create a list of days(integer) from a list of dates(date).
I tryed to do this....
[Code]...
View 4 Replies
Aug 31, 2011
I don't know if this is doable, maybe with Linq, but I have a List(Of MyType):
Public Class MyType
Property key As Char
Property description As String
End Class
And I want to create a Dictionary(Of Char, MyType) using the key field as the dictionary keys and the values in the List as the dictionary values, with something like:
New Dictionary(Of Char, MyType)(??)
Even if this is doable, internally it will loop through all the List items, I guess?
View 3 Replies
May 26, 2012
y have this class
Private Class MyClass
Public Property propertyOne() as String
Public Property propertyTwo() as String
[code].....
View 2 Replies
Apr 27, 2012
I figure I should use 'Aggregate' but apparently I am getting it wrong First I get a list of my Entity objects Dim employers As List(Of myEntity) = (New XXXX()).getZZZ(userName, userType) Then I figured this would be a way to put all the names in a string Dim names as String = employers.Aggregate(Function(current, [next]) current.Name & " " & [next].Name)
[Code]....
View 2 Replies
Dec 22, 2010
I have 2 classes
Public Class Shipper
Public Property ShipperID As Long
Public Property CreateDate As DateTime
[Code].....
View 1 Replies
Jan 25, 2011
I have two generic lists, named ListA and ListB. Both ListA and ListB could potentially have duplicate items. What I would like to do is use LINQ to grab the items in ListB that are not in ListA, but I'm unsure how to do so.
View 8 Replies
Jul 29, 2010
This is what I want to do as seen in C#(loop against a list and fill another list from its data using Linq)
[Code]...
View 1 Replies
Feb 9, 2011
NET 3.0. Is there a Distinct on List(Of T)? What packages would I need to import? If not, is there an equivalence?
View 4 Replies
Jun 6, 2012
since this
(vb.net)
Dim test As New List(Of Integer())
test.Add(New Integer() {1, 2, 3})
test.Add(New Integer() {1, 3, 3})
test.Add(New Integer() {3, 2, 3})
[code]....
does not work, how would you do the distinct?
View 2 Replies
Mar 28, 2011
I am writing app in vb.net
I have two variables one with list of RoomRate and other with list of RoomTypes.
We have RoomRates and RoomTypes linked with RoomTypeInfo variable insite the RoomRate.
So how do i find the RoomTypes which donot have the RoomRates Defined.
My Sample Code:
class RoomType
property UIN as integer
property Title as string
end class
[Code]......
View 2 Replies
Jun 30, 2009
I'm basically brand new to LINQ. I've seen some examples that allow me to strong type objects using LINQ but I don't really understand them because they're in C#, which I guess lets you do different things with LINQ(I think?). [Code] I just want to get a list of all the products from the XML doc and put them into a Generics list.
View 3 Replies
Jul 13, 2010
I am trying to distinct on multiple columns and get datarows from datatable. but getting error.
Dim query As IEnumerable(Of DataRow) =
(From row As DataRow In SourceTable.AsEnumerable() _
Select row.Field(Of String)("ColumnName1"),
[Code]....
I want another datatable with distinct row based on given columns from SourceTable.
View 3 Replies
Feb 7, 2012
On to my question.I have a List(of String) that contains multiple items in each index.
A list declared as:
Dim NewStrings As New List(Of String)
May contain the following:
item (0) - (1 MKNO ABC 2.45 STND 3.3)
item (1) - (1 MKGO ABC 1.34 STND 2.5)
item (2) - (1 MKNO ABC 2.45 STND 3.3)
item (3) - (1 MKNO ABC 2.45 STND 3.3)
[Code]...
View 3 Replies
May 14, 2009
II am trying to create a toggle button that switches a list to a range and then back to a list if needed. I am able to get it to do both but when I add an item to the list, convert to a range and then convert back to a list it leaves off the last items I entered.I tried to work in a code to select all cells but I must not be putting it in the right place.This is what I have so far:
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$3:$AE$7"), , xlYes).Name = _
"List1"
I realize the problem is the $AE$7 (the $A$3 is correct)
View 1 Replies
Nov 8, 2011
I load a list from a database like the example below. The class has more properties that the database table holds so when I load the list from the DB, there are Null values for certain properties of each item in the list. When I try List = List.Distinct.ToList, it never works (when null values are present).
[Code]...
View 7 Replies
Mar 6, 2012
I want to display distinct items from a column in a checked list box then make a selection or selections and perform commands based on info from a second column in that database the database is a small Access 2010 database in the application directory right now I added the data source and items dont display even though I selected that source in the checked list box properties
Dataset = MyDataSet1
CheckedListBox = MyListBox1
I tried it with a combo box and it shows items but includes duplicates, did I setup the datasource wrong?
View 2 Replies
Feb 8, 2011
I need to get a list of distinct names inside the data table and the sum of values for each one. I know some basic stuff about linq, but i don't know how to put the distinct and the sums together.
The SQL Query:
SQL
SELECT DISTINCT username,
[Sum1] = SUM(day1),
[Sum2] = SUM(day2)
[Code].....
View 1 Replies
Oct 24, 2011
i am trying to create a list of list in that i would like to work on multiple accounts at the same time. lets say i have 5 accounts. every account has a seperate name. each account has a few fields. so i though of having a list of bookkeeping (with 5 accounts) and a list of accounts (with expense, income, tax, status, etc as fields). [code] and if the idea of using list of list works how do i loop through both lists.
View 6 Replies
Jun 2, 2011
I would like to create list of child objects from list of parent object. Like If i have list of bookingroom which has one member room then i would like to create list of room from it.
eg. code:
Dim BookingRoomList As List(Of BookingRoom) = New List(Of BookingRoom)
Dim RoomList As List(Of Room) = New List(Of Room)
BookingRoomList = BookingRooms.FillGrid()
[Code]....
Is there any short cut method instead of iterating over for earch?
View 1 Replies
Oct 26, 2011
This is probably a really basic question - but I have a list of items (custom objects) being passed from one winform (.net 3.5) to another. I want to create a local list to store changes that only get persisted if the user clicks save. Currently if the user clicks cancel - the changes are still applied in the first form because I assume the objects are reference type.I have the save working as it calls a service layer to do the save and then refreshes the other form - but not the cancel.
View 1 Replies
Dec 15, 2010
I got an object of List<List<string>>I need to bring this into a ist<string>I have no idea how to do this with LINQ.
View 1 Replies
Jan 20, 2011
If I create a list for a TextBox:
[Code]....
I am able to only add controls that are of type TextBox. My question to you is, can I create a List to hold more than one control type or do I have to create a list for each control type?
View 8 Replies
Dec 15, 2009
I have a variable declared as...
Dim MyList as List(Of String)
I would like to create an array of these lists of string.
Something like....
[code].....
View 14 Replies
May 11, 2011
I am trying to use linq to query a List(of T) object, but when i type in my linq statement it comes back with the following error: Error57Expression of type 'System.Collections.Generic.List(Of BreakoutData)' is not queryable. Make sure you are not missing an assembly reference and/or namespace import for the LINQ provider.D:\Code\OLGA35\BreakoutByBusinessUnit.aspx17025D:\Code\OLGA35\
I have looked at my web.config and I have the imports:
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
[CODE]...
I have put in several imports at the top of my page, but that hasn't helped
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="System.Core" %>
[CODE]...
I'm not sure what to do at this point.
Here is the code that is relevant:
Dim ListCollection As List(Of List(Of BreakoutData))
Dim GroupList As List(Of String)
Dim DataList As List(Of BreakoutData)
[CODE]...
Everything i've found on google just says to add in the System.Core, System.Data.Linq references, but as far as I can tell it all is setup correctly
View 1 Replies
May 25, 2009
I am trying to use linq to query a List(of T) object, but when i type in my linq statement it comes back with the following error:
Error57Expression of type 'System.Collections.Generic.List(Of BreakoutData)' is not queryable. Make sure you are not missing an assembly reference and/or namespace import for the LINQ provider.D:\Code\OLGA35\BreakoutByBusinessUnit.aspx17025D:\Code\OLGA35\
[code].....
View 6 Replies
Jun 8, 2011
I'm using a program see here: Visual Basic Regular Expression Question. I enter letters and the program returns all possible combinations from list. I want change this line of code...
Dim result = fruits.Where(Function(fruit) Not fruit.Except(letters).Any())
If I have this list:
Dim fruit as List(Of string) from {"apple","orange","pear","banana"}
And I input "p a p l e r" then it would return "apple" and "pear", but if I enter "a p l e r" then it would return just "pear". The idea is to return all words, which can be made of entered letters without duplicating any single letter. How to optimize this Linq code?
View 1 Replies
Sep 2, 2011
Dim query = From o In myContainer.MyObjects Select o.MyStringProperty Distinct
Dim myProperties As List(Of String) = query.ToList????? 'no way!!!'
"query" type is IEnumerable(Of String)
I tried to use the query directly as a DataSource of a (infragistic) combobox, but it throws me NullReferenceException, so I decided to convert it to a listof strings, to be a more "classical" datasource.
Dim values As List(Of String) = query.AsQueryable().ToList()
does not work either: Value of type 'System.Collections.Generic.List(Of System.Linq.IQueryable(Of String))' cannot be converted to 'System.Collections.Generic.List(Of String)'.
View 3 Replies