I am converting data table content to string, Say the dataset has 12 rows and 8 column. At the end, the Dict contain 12 rows or 96 columns. what's wrong with my code below, how do I reset the row?
Dim ds As DataSet = ClsDB.GetDataSet(sql)
If Not ds Is Nothing AndAlso ds.Tables.Count > 0 Then Dim row As New List(Of KeyValuePair(Of String, String))
gefundeneID = drTerminal.AsEnumerable().Single(Function(s) s("TerminalID") = RandomID)Have an array of DataRow and want to look if the RandomID is in one of the rows.What's wrong with this code?
I am trying to merge multiple datacolumns in a datatable. Eg. The address data is stored in a different columns such as, Housename, street, city and postcode. I want to merge those datacolumns in to one and put it into one datacolumn as "Address".
I'm having trouble getting a Linq to Sql query to work. Basically, I want the sum of a column in a table for only rows matching a certain condition. A simplified version is this:
Orders = order that contains products OrderProducts = relational table containing products that are in an order Products = table containing information about products
I can get the total sum of the qty of products like this:
Dim totalQty = requests.Sum(Function(p) p.OrderProducts.Sum(Function(q) CType(q.ProductQty, Nullable(Of Integer))))
(Requests is a IQueryable of Orders)But I also need to get the sum of qty where the actual product meets a certain condition. Something like...
Dim totalQty = requests.Sum(Function(p) p.OrderProducts.Sum(Function(q) CType(q.ProductQty, Nullable(Of Integer))))... WHERE p.OrderProducts.Product.ProductAttribute = true
How would I go about getting that query with the additional where clause to only get the sum of the qtys where the productAttribute = true ?
I have the following query which groups some records and then filters where the count of the grouped records is 1.
I'd like to take the returned result and perform another query to retrieve the entire record from the JobcodesWorkingRollup table where the ParentNode column equals the result of this query:
Dim query = From r In context.GetTable(Of JobcodesWorkingRollup)() _ Group r By r.ParentNode Into g = Group _ Where g.Count = 1 _ Select New With {.cnt = g.Count, .nm = g.FirstOrDefault.ParentNode}
Why can't I get any values back when I use Linq to Sql? BHS_TimeSheet is my database table in which have some records. Model.TimeSheet is a class I create in the model. Private db As DataFactoryDataContext
Today I ran into an issue with LINQ to objects (not SQL) that popped up due to a typo. I had a .Select one place and a .Where in another place. I was expecting same result but they are showing different numbers. Assume somelist has 10 elements with all elements having qty = 0
I have seen different examples in Linq and one used Select and another didnt but both return the same results. Is there a reason why we should use Select ?
I can't quite figure out why this Linq Statement isn't working as i would expect:
[Code]....
I would assume that this would create a new collection of anonymous types, that would be distinct. Instead it creates a collection the size of the "ThisParentCollection" with duplicate "MyAnonymousType" in it (duplicate id's).
Is it possible using Linq to select the FirstName and LastName out of all the Bloops in the collection of Bloops and return a collection of Razzies? Or am i limited to a For-Loop to do my work?
To clear up any confusion, either VB or C# will do. Also this will probably lead to me asking the question of (What about using a "Where" clause).
I have a single columned datatable inside a single tabled dataset.I just want to convert this dataset to distinct rows. Here is my code, it gives compile error '.' expected.
Dim query = _ From email In ds.Tables(0) _ Select email.Field<string>("Email").Distinct()
EDIT: I changed to (Of String) and it works... BUT NOW 'query' is an ienumerable collection of characters... not a datatable... so how do I convert back easily without manually doing a loop?
Linq to SQL query to Select the maximum "MeanWindSpeed" value? The database name is "WeatherArchives" The TableName is "TblValues" The Column is "MeanWindSpeed" And Also, I would like to have a query to get me the Max "MeanWindSpeed" in each year,
Dim MyQuery = From c In xdoc.Descendants() _ Where c.Attribute(OriginY) IsNot Nothing _ Order By Val(c.Attribute(OriginY).Value), Val(c.Attribute(OriginX).Value) _ Select c.Attribute(UniStr)
Right above you can see my First! linq attempt! And here comes my first question.
How can i select more than one column in a linq query in vb.net?
For example... Select c.Attribute(UniStr) AND c.Attribute(OriginY)
I need to have a query which list all the user according to the date value in the database. Problems is this, in the database the date format is 5/5/2009 4:30:12 but I want to compare with 5/5/2009. I think the value of the based date is 5/5/2009 12:00:00 and that's why I couldn't query it.
The query is something like
dim db = new databcontext dim user = from u in db.datacontext where u.signUpTime = 5/5/2009 select u.
Dim groupedData = (From p In pData _ Group By p.TruncParam Into Group) _ .SelectMany(Function(g) g.Group) _ .Select(Function(d, idx) New With { _
[Code]...
When the TruncParam changes, I would like the index (idx) in the Select clause to reset to 1. So, in the list above, the Index should be SOLUB0001, SOLUB0002, INSOL0001, INSOL0002...CLRES0001, SUMCA0001, SUME0001.
I am trying to replace tasks.IndexOf(t) + 1 with something a little simpler. Is there any built in functionality for this? Hrmm xml literals do not seem to translate well on here....
I was wondering if there is a neat way do to this, that DOESN'T use any kind of while loop or similar, preferably that would run against Linq to Entities as a single SQL round-trip, and also against Linq To Objects. I have an entity - Forum - that has a parent-child relationship going on. That is, a Forum may (or in the case of the top level, may not) have a ParentForum, and may have many ChildForums. A Forum then contains many Posts.
What I'm after here is a way to get all the Posts from a tree of Forums - i.e. the Forum in question, and all it's children, grandchildren etc. I don't know in advance how many sub-levels the Forum in question may have. (Note - I know this example isn't necessarily a valuble use case, but the Forum object model one is one that is familar to most people, and so serves as a generic and accessible premise rather than my actual domain model.)
I have a listbox that is dynamically filled by certain values depending on what table has been selected from another list box. Once a value is selected, it is being graphed vs a date & time range. With my ignorance of linq: depending on what value is selected, the linq to sql statement I need to create to grab data from my database is different as I can't use an index on an anonymous type.
result = From t In db.APS _ Where t.DateTime >= startDate And _ t.DateTime <= finishDate And t.Weight = weight _ Select t.DateTime, t.TotalConcentration
t.TotalConcentration should be selected if my listbox value is "Total Concentration", but if it's something else, like "Temperature" or "Flow Rate" (connected to appropreate database columns) - this method obviously isn't going to work. I need to be able to dynamically select a specific column from the anonymous type list, or use some other method I'm unaware of to do this.