.net - Linq, Map List To CheckboxList
Dec 17, 2009If I have a List(Of Guid) can I map those Guid's with a single Linq expression to a CheckboxList of values?
View 1 RepliesIf I have a List(Of Guid) can I map those Guid's with a single Linq expression to a CheckboxList of values?
View 1 RepliesI have 3 tables:
CustomerType
CusID
EventType
EventTypeID
[code]....
Then I want it to automatically insert data into CustomerEventType table based on the last EvenTypeID data that's just inserted and the checks of the CusID that is using CheckBoxList1 bounded from CustomerType (Suppose there are 2 IDs. )After I Click on Insert button the data in EventType table and CustomerEventType table should be:
EventType
EventTypeID
1
CustomerEventType
[code]....
The only question that I have is, what should be the code behind the insert button using VB.NET LINQ-to-SQL to get this result?
y have this class
Private Class MyClass
Public Property propertyOne() as String
Public Property propertyTwo() as String
[code].....
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)
I have 2 classes
Public Class Shipper
Public Property ShipperID As Long
Public Property CreateDate As DateTime
[Code].....
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]......
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 RepliesI'm trying to create a list of days(integer) from a list of dates(date).
I tryed to do this....
[Code]...
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]...
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]......
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 RepliesI 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 RepliesI 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
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].....
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?
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)'.
I trying to do what seems to be a simple thing but I'm having problems. The answers I find aren't working. I'm still getting casting exceptions:
Dim query = (From l In dePhl.cv_phil Where l.batch = strMmddyyyy
Select l.zipfile.Distinct)
Dim objFileList As List(Of String) = query.ToList() 'Error
[Code]....
Assume I have the following XML file:
<Movies>
<Movie ownerName="Ryan">
<Title>The Lord of the Rings Trilogy</Title>
[code].....
Public Sub adjectAllNormals()
Dim qry As LinkedList(Of CElement) = From elm In Elements
From id In SelectIDs()
Where elm.ID = id
Console.WriteLine(qry.Count)
End Sub
I have recently started using vs2008 for the linq feature but am having problems using it with a sorted list.my sorted list has a key of timestamp.I want to retrieve the first item from the sorted list having (key) timestamp <= myTimestamp.
View 8 RepliesI am a bit new to linq, I am only using linq for filtering the data. [code]...
Con.Numbers is a dictionary, but now I converted it into a list, hence the above code wont work with list[code]....
I am trying to learn some VB.NET for my coo-op that starts next week, and for that reason i took my portfolio web site that is on C# and just started to converting it to VB.NET to get familiar with the syntax.
I am sure my problem is simple however i have a hard time solving it. I am trying to grab data with the linq query and then return it as list to bind to the Repeater.I have the following function:
[Code]...
And it would work fine. However if I try to use ToList() in VB.NET i am getting error that it cannot convert it from ling to sql List to the generic list. How do i do this convertion in VB.NET ? or maybe there is another way ?
I am decent when it comes to C# however somewhat lost with the VB.NET syntax.
'Read RESX file and returns a List(Of ResXDataNode)[code]...
Provide two separate copies of the node? Or will the List and Linq query still be referencing the same data?
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?
I need to take a collection and group it via Linq but all the examples I've seen fail in some manner or other with some syntax difference that I can't quite lick.
My collection:
Dim a As New List(Of ProcessAlert)
a.Add(New ProcessAlert("0000112367", "5551110000@txt.att.net", "Alert", 2))
a.Add(New ProcessAlert("0000112367", "5551110000@txt.att.net", "Document", 2))
[Code].....
I am using LINQ - VB.Net I want to filter my List object by passing String object in the where.
Dim _permittedTransactionCodes As List(Of String) = Nothing 'String object
it is populated with data.
Dim tap100transCodeInfos As List(Of Tap100transCodeInfo) = _dal.GetActiveTap100transCodeByHdrScreenCde(UCase(screenId), "TRAN_CDE")
i am trying something below, but not getting the filtered results
tap100transCodeInfos.Where(Function(x) _permittedTransactionCodes.Contains(x.TranCde))
I have list object and I need to check id in a comma separated string using LINQ in VB.NET, something like this:
dim strId as String = "1,2,3,5,"
dim myList = from objmylist where objmylist.id in (strId)
How do I order by a passed string value on my list of objects? i need to do paging and sorting on my List(Of) objects the paging is no problem but I don;t know who to get the Order By to work.Here is what I am currently doing and it's working great:[code]
View 4 RepliesI am trying to get an index of a List(Of Details) Details being a class i use instead of an annon method. Is it because i am using array.findindex when it's not an array but a list(Of???
Dim index As Integer = Array.FindIndex(Details, Details.FirstOrDefault(Function(nd) nd.Name = "name"))
Error1Data type(s) of the type parameter(s) in method 'Public Shared Function FindIndex(Of T)(array() As T, match As System.Predicate(Of T)) As Integer' cannot be inferred from these arguments. Specifying the data type(s) explicitly might correct this error.
There are plenty of seemingly related Linq questions, however a quick browse through the content doesn't seem to answer my question specifically enough for my limited intelligence to grasp.
We have a table named PropertyInteractions in which is stored threaded messages via a thread id, the thread identifier is the Id of the initial interaction record. Given the following Linq query (which retrieves all interactions concerning a user), how might I split interactions into lists of PropertyInteractions grouped by Id?
[Code]...