C# - Get Access To An Incrementing Integer During LINQ Select

Dec 1, 2009

[Code]...

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....

View 3 Replies


ADVERTISEMENT

Select Integer From An Access Database Using SQL?

Dec 3, 2010

Trying to select an integer from an Access Database using an SQL statement in VB[code]...

View 5 Replies

Asp.net - LINQ - Putting Result In A Dictionary(Of String, Integer), Where The Integer Must Be 0?

Sep 19, 2011

I have a LINQ2Entity problem, I want to get the value, string, from a database, so I select FProducts.Serial_number, and to end the query, I do .ToDictionary. The problem is, it tells me that it doesn't have sufficient parameters, to convert ToDictionary. So I need something like select FProducts.Serial_number, Nothing). ToDictionary. Also FProducts.Serial_number, 0).ToDictionary doesn't work.

Sub GetStatistics(ByVal ProductNumbers As List(Of String), ByRef Passed As Integer, ByRef FailedProducts As List(Of String))
Passed = 0
FailedProducts = Nothing

[Code]...

View 2 Replies

Value Of Type 'System.Linq.IQueryable(Of Integer)' Cannot Be Converted To Integer?

Aug 11, 2011

I am new to EF Linq and I have been struggling with this query for a few days. From reading this forum, I have managed to get this far:

Dim noPic = (From f In myEntities.FriendLists
Where (f.UserID = Profile.ID)
Select f.FriendID).Except(From g In myEntities.GuestLists
Where g.EventID = _id
Select g.FriendID)

[Code]...

I am trying to get everybody from the FriendList who is not already on the GuestList to display in a Repeater control. After reading the forum I was able to append .First() to noPic at the myNoPic declaration and finally get a result but that only gave me the first element. Does anybody have any advice on how to accomplish this?

View 2 Replies

Integer Datatype Not Work In Linq To Sql?

Mar 15, 2011

I face a problem that if i make a datattype in sql server of Integer and then use it in linq to sql query it give error of "specific cast not valid" and when i change datatype into varchar the linq to sql query work fine one more thing how to use linq to sql query to make crystal report?

View 2 Replies

LINQ With Integer Array LOGIC

May 24, 2010

Apologies if this is the wrong forum (the other LINQ based ones didn't seem appropriate). I'm writing a very simple code crack game, a player enters FOUR numbers in a text box which are compared against the random number generated on form launch. Random number generator

[Code]...

View 15 Replies

Get The Corresponding Key For The Maximum Value In A Dictionary(Of SomeEnum, Integer) Using LINQ?

Dec 11, 2009

I've got a Dictionary(Of SomeEnum, Integer) that gets filled up while looping through some objects that have a property with type SomeEnum. Once the loop is done, I want the SomeEnum type that occurs the most in the list of objects. I also need the other counts as well for display purposes, hence the usage of a simple Dictionary(Of K, V).I am looking for a LINQ query to give me back the SomeEnum key that occurs the most by looking at each keys number of occurences. Or perhaps there's an easier way of going about it.I could do this:

Return (From kvp As KeyValuePair(Of SomeEnum, Integer) _
In Me.MyObjects Order By kvp.Value Descending _
Select kvp).First().Key

But wouldn't the sorting be a more expensive operation than trying to wiggle Max() in there somehow?

View 1 Replies

C# - LINQ To Object Comparing Two Lists Of Integer For Different Values?

Sep 19, 2010

I accept both C# and VB.NET suggestion, even though I'm writing an app in VB.NET I have two lists of intergers

List1 {1,2,3,5}
List2 {2,4,6,7}

I want to have new List3 {4,6,7} which is composed of elements of List2 that are not in List1. I know I can write a nice For Each loop for this but I want it done in LINQ I've been looking for such methods at Enumerable Methods, but I can't find it.

View 2 Replies

Comparing Different Integer In Select Case For Different Purpose?

Feb 23, 2009

I have a question regarding Select Case. I am comparing different integer in select case for different purpose. I want to run some code on the case when number is not from the list of below mentioned.Can i use this as i mentioned below in Select case?. If not then what does mean. It don't give me any error. Case Is <> 307, Is <> 1, Is <> 12, Is <> 14, Is <> 56ThanksDalbir Singh

View 3 Replies

Passing List Of (integer) To Select Statement?

Mar 27, 2012

I have a function that returns a Datatable. I am passing a list of Integer as an argument. Then I thought tis would work.

Public Function GetEventsByEventType(ByVal EventType As List(Of Integer), ByVal DayInterval As Integer) As DataTable
Using con As New MySqlConnection(strCon)

[Code]...

as you can see. I use string.join to convert the list of integer to something like this. '1,2,3'. Problem is that is read as a string so i get the incorrect results. I need to have where EventType IN(1,2,3).

View 2 Replies

VS 2010 PictureBox-Using An Integer To Select An Image?

May 2, 2012

To use code to select an image for a PictureBox I can do this:PictureBox.Image = My.Resources._1, where 1.png is the name of the image file I want seen in the PictureBoxI want to use a randomly generated integer to select which image is seen in the PictureBox.5 would select 5.png12 would select 12.pngThe .png files are already in the Resources folder.I can generate the random integer and have it in an intVariable but I don't know how to use it to to tell the PictureBox Image property what to do.

View 2 Replies

Select Inside Select With Microsoft Access 2010?

May 13, 2012

am developing a project and i am trying to use this code with my table which is under microsoft access 2010

View 3 Replies

.net - Syntax Error With Select In Select In Vb To Access SQL?

Apr 14, 2012

I got a SQL statement where am selecting from an access database in vb but I get this error; "syntax error in query expression select sum(brought_qtty)" when I run my program. I imagine am doing the right thing but seems am not. How can I adjust this select? The code is below:

"select distinct(brought_price) as [Price], select sum(brought_qtty) as [Ordinary] from brought_coffee where " & _"coffee_grade=O, select sum(brought_qtty) as [Premium] from brought_coffee where" & _"coffee_grade=P, sum(brought_qtty) as [Total Qtty]" & _", sum(brought_paid) as [paid], " & _"sum(brought_bal) as [Balance]" & _"from brought_coffee, farmer where brought_date=#" & dtc.Text.Trim & "# and farmer_centre='" & cc.Text.Trim & _"' and farmer.farmer_num=brought_coffee.farmer_num"

View 1 Replies

Asp.net - LINQ To SQL - Select SUM With A WHERE?

Aug 17, 2009

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 ?

View 1 Replies

Linq To SQL Sub Select?

Oct 12, 2009

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}

View 1 Replies

Asp.net - Linq Select Compound From

Apr 16, 2009

I'm experimenting with linq compount selects. I find the following query not to return any element:

Dim q = From s In d.GetChildRows("DossierSinistri") _
From i In s.GetChildRows("DossierIncarichi") _
Select s

[Code].....

View 2 Replies

Asp.net Mvc - Why Can't Get Anything Back When Use Linq To Sql Select

Feb 3, 2011

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

[Code]...

View 1 Replies

C# - Linq Ambiguity On Where And Select

Nov 15, 2011

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

[Code]...

View 4 Replies

LINQ Select In .NET And C# Differences?

Mar 16, 2011

When using VB.NET I can do the following:

Public Function GetUser(ByVal ID as Integer) As User
Dim dc As New YesEntities()
Return (From u in dc.Users Where u.ID = ID).Single()
End Function

And on my .aspx/.vbhtml page I can access the user's department name like this:

Dim DepartmentName as String = new User().GetUser(12).Department.Name

[Code]...

View 1 Replies

Select Controls Using LINQ?

Jul 25, 2010

i try to select controls using LINQ but it show error

here is the code:

Dim testcontrol As VariantType
testcontrol = From cControl As Control In Me.Controls.OfType(PictureBox) Select cControl Order By Name Ascending

[Code].....

View 2 Replies

[2008] Using Select With Linq

Jan 9, 2009

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 ?

[Code]...

View 1 Replies

.net - Linq To Object - Select Distinct

Mar 18, 2010

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).

View 1 Replies

C# - Linq Select Certain Properties Into Another Object?

May 28, 2009

So say I have a collection of Bloops

Class Bloop
Public FirstName
Public LastName

[Code]....

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).

View 4 Replies

C# - Select` And `sub` Have Brackets Around Them In VB Linq Expressions?

Jul 12, 2011

I converted the following query from C#:

src.Select((c, i) => src.Substring(i)).Count(sub => sub.StartsWith(target))

To the VB.NET query:

src.[Select](Function(c, i) src.Substring(i)).Count(Function([sub]) [sub].StartsWith(target))

Using Developer Fusion. I was just wondering why the VB.NET version has [] throughout.

View 3 Replies

LINQ / Select Distinct From Dataset?

Aug 20, 2010

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?

View 1 Replies

Linq To SQL Query To Select Maximum Value

Jun 21, 2010

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,

View 1 Replies

Select Distinct In Linq Query?

Jan 4, 2012

I've a collection with the data like this.[code]...

how can select the distinct data using linq?

View 2 Replies

Select More Than One Column In A Linq Query?

Nov 2, 2009

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)

View 1 Replies

Select Only Date Value No Time In LINQ To SQL?

May 17, 2009

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.

View 1 Replies

Select Two Datacolumns From A Datarow In Linq ?

Aug 23, 2010

Dim orders = From tt In testTable _
Order By tt.Item("OrderNumber") _
Select tt.Item("OrderNumber"), tt.Item("OrderId")

This is breaking. Is there a way to do this? I would have thought it was easy enough. Obviously, I thought wrong....

View 1 Replies







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