VS 2008 : Linq To XML - Getting Top #?

Oct 8, 2009

if there is a Linq way of doing a TOP to only select part of a datatable? Unfortunately the data won't have it's key yet at the point that I need to do this (in fact, it's the key that we are trying to get back to in the end) so I can't use a where clause that looks at the key and gets the items between a range. Looking for something that's is the equivelent to SELECT TOP 1000 a,b,c FROM ABC ... but in Linq.We're using Linq to XML to transform a datatable to xml, then send it on over to SQL Server for processing. That works fine and dandy - and amazingly fast.

How ever, I've run into a problem where my datatable has an unusually high amount of records (for the type of data that it is). I need to move data on the order of 60k records to the database at some point. currently we're looping through the DT and calling the sproc.... if I did the numbers right, that will take somewhere around 33 hours... easily not an option. Ok, so our best option is to transform the DT into an xml document and send it off, then deal with the data in set transactions. Problem is that I just can't see us sending 60k rows worth of data all in one shot like that....

View 5 Replies


ADVERTISEMENT

VS 2010 Upgrade From 2008 To 2010 - Now LINQ - IntelliSense Is Not Working For LINQ Stuff

Apr 20, 2010

I just upgraded a project from VB 2008 to VB 2010. Before, the project did not use LINQ. I have started implementing it. So, I have updated the target framework from 2.0 to 3.5, and added a reference to System.Core, and imported the namespace System.LINQ to the entire project and also imported System.Data.LINQ into the form I'm working with (because it was not available in the list for Imported Namespaces in the references tab).

It's not throwing any errors now, but my IntelliSense is not working for LINQ stuff.

For example... I write this:

[CODE]....................

Then, if I type S. on the next line, the IntelliSense doesn't grab what it should for S (Only get Equals, GetHashCode, GetType, ReferenceEquals, and ToString, instead of the options I should get like Count, First, FirstOrDefault, etc...). If I Type S.First. then its the same thing, no IntelliSense that lists the available fields for S, just the standard options (Equals, GetHashCode, GetType, ReferenceEquals, and ToString). I should be seeing my column names in my table when I type S.FirstOrDefault.

So any ideas what is going on? When I type the code, for example, MessageBox.Show(S.FirstOrDefault.FirstName), it works perfectly. But it doesn't change the casing of the text (so it would read s.firstordefault.firstname) and no intellisense while doing it. But no errors. BTW - Everything works perfectly when creating a NEW VS 2010 application, it's just my projects upgraded from Visual Basic 2008 that have this issue.

View 2 Replies

.net - ActiveRecord Linq/NHibernate Linq Not Building Query Completely?

Jul 14, 2011

given this function:

Public Function Search(ByVal StartIndex As Integer, _
ByVal MaxResults As Integer, _
ByVal AccountNumber As String, _
ByVal LastName As String, _

[Code]....

instead of what I expected:

Select count(*) from remitline where lastname = "smith"

What am I doing wrong building up the where clause? I'm using Castle ActiveRecord 2.1

View 1 Replies

Performance Gain In LINQ Query Vs LINQ Stored Procedure?

Aug 6, 2009

if there is that much of a performance gain in running a LINQ stored procedure versus a LINQ query?

View 1 Replies

Connect ADO And LINQ In 2008 .NET 3.5?

Jun 16, 2010

I am loading al lot of data from a server to a local PC. Then i crate a disconnected table localy and move data from the server to the local PC.Then to update the userinterface (Wondows forms datagridview) i think i will use Linq ti move from this local tabel to the datagridview. On server there is 1000 000 rows in first tabel(source), to the user i have 30 000 rows each time the user loads forms and greate a smaler local table.That is once a day. But each time the user move to next row in datatabel there is 12 rows from my local table who is printed into the a new datagriview.How do i connect Linc to my ado table ?

View 2 Replies

Use LINQ In Vs2008 Using .net 2008?

Aug 4, 2011

send me a little desktop application using vb.net and sql server in which LINQ concept is cleared, how to use LINQ in vs2008 using vb.net 2008

View 3 Replies

Using Dynamic LINQ In Vb 2008?

Oct 17, 2011

This is an extension of my last question which was answered, so I am starting a new thread. I have a query in LINQ that I was given to trim down the columns of a datatable. This works well, however, I need to make the LINQ query dynamic. So the query below:

Dim qColumnsIWant = From row As DataRow In inDT.AsEnumerable() _
Select _
EPN = row.Field(Of Integer)("EPNID"), _
EPNID = row.Field(Of String)("EPNNumber"), _
Ingot = row.Field(Of String)("Ingot"), _
ShopOrder = row.Field(Of String)("ShopOrder")

View 5 Replies

VS 2008 Major LINQ To Xml?

Apr 21, 2010

it works absolutely perfectly. I add nodes to the xml document, then I add child nodes using linq query to pull data from a datatable.My problem is. After the LeanerBiographical Node I want to add another node, but when I try the code i higlighted in blue, which needs to go in after the code highligted in red I get this error:Range variable name can be inferred only from a simple or qualified name with no arguments.for the life of me I can't get tgis to work and I need it on Friday. plz plz help me LINQ experts

[Code]...

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

Linq To Entities. GetPropety(name).GetValue Not Recognised By Linq?

Apr 20, 2011

I have a listbox on my xaml form that I bound to a List(Of MyType) property. I populated this list like so:

Dim fields As List(Of CheckableFields) = New List(Of CheckableFields)
Using context As ITIPEntities = New ITIPEntities()
Try[code]....

Now I'm at the point where the user selects the fields they want included in a report and I need to iterate over the required fields. This is my linq query:

For Each checkedField In _requiredFields
If checkedField.IsChecked Then
If checkedField.FieldData IsNot Nothing AndAlso checkedField.FieldData.Trim IsNot String.Empty Then[code].....

View 1 Replies

VB 2008 LINQ To SQL Classes - How To Use App Role

Feb 18, 2010

I am curious as to the proper technique to use SQL Server's AppRole with a LINQ to SQL Class. I understand I have to establish the intial connection with no connection pooling. However, do I simply call the SQL stored procedure sp_setapprole using standard LINQ before executing any of my methods that interact with the database, or is there a better way to enable and use AppRole within the LINQ to SQL class?

View 6 Replies

VS 2008 - LINQ Group By Datatable

Feb 21, 2012

syntax of the LINQ query to use GROUP something BY something and select some fields of the datatable. i am having a datatable filled with some rows, i am trying to fill the datagridview with the GROUP BY query output of some fields.

View 4 Replies

VS 2008 Convert SQL Statement To LINQ?

Oct 28, 2009

I'm just getting my feet wet with LINQ but am struggling to convert this SQL statement to LINQ.

Dim SQLString As String = "SELECT MESSAGE_ID FROM " & Schema & _
".PPM_TRANSFER_EMAIL WHERE TO_CHAR(IMPORTED_DATE,'YYYY/MM/DD') <= '" & _
DeletionDate.ToString("yyyy/MM/dd") & "' AND IMPORTED = 'Y' AND FILE_NAME LIKE '" & _
mb & "%'"

I have a Dataset that already contains all the data from the PPM_TRANSFER_EMAIL table so it seems silly to query the database again when I can use LINQ to query the dataset.

View 1 Replies

VS 2008 Linq - The EvensQuery And Num Are Not Defined?

Apr 18, 2010

In this following

[code]...

in the query creation part,the evensQuery and num are not defined.....then how does it work Secondly,i read this from MSDN:In Visual Studio you can write LINQ queries in Visual Basic or C# with SQL Server databases, XML documents, ADO.NET Datasets, and any collection of objects that supports IEnumerable or the generic IEnumerable<(Of <(T>)>) interface Now how can i know whether the collection of objects supports IEnumerable<(Of <(T>)>) interface or not?

View 10 Replies

VS 2008 Linq 2 Entities Can't Add An Association

Mar 21, 2009

I'm a bit of a n0ob to all this and I'm having trouble finding good resources on the net.What I'm trying to do is define a one-to-many relationship between two entities. I'm using the GUI tool in Visual Studio - and have created the tables in Microsoft SQL Server Management Studio.Basically, I have two tables....a 'Users' table and a 'Sites' table. A single user can have many sites associated with it.Users has a primary key of 'UID' and the Sites table as a primary key of 'Site_ID'.Sites also has a column 'UID' that should indicate which user that site is associated with.Anyway - it sounded pretty simple; but no matter what I attempt to do, I can't seem to get it to work. Mostly, I get validation errors - sometimes run-time errors, or sometimes, no actual data even though there should sites that match the UID of the user.I am able to connect and write LINQ against my Users table/pull down User objects - but can't seem to get it to know that the Sites are associated with the user.In the GUI - if I go to 'Add Association' and create a 1 to many link between Accounts and Sites - and Validate - I get an error saying, "Error1Error 11008: Association 'AccountsSites' is not mapped."

It seems like, when I try to make an association, it wants to link the 'Keys' of each entity.But U_ID and SITE_ID are the keys and, obviously, shouldn't match.If I click on the line it created in the GUI and I go to 'Table Mapping' I can see that it is trying to match those keys. Since I want it to match user_ids my first thought is to just make the U_ID the entity Key in the Sites entity but, of course, that's wrong because it would no longer allow a 1 to many relationship.

View 1 Replies

VS 2008 LINQ Get The Index Of Datagridview Row?

Apr 29, 2012

vb
Dim CheckedRows = From dgv As DataGridViewRow In Me.DataGridView4.Rows _
Where dgv.Cells(0).Value = True _
Select New With {.a = dgv.Cells(1).Value, .b = dgv.Cells(2).Value}

my code above works fine but how to get the index of the row on which the checkbox is checked

View 5 Replies

VS 2008 LINQ Not Returning Results?

Mar 3, 2010

So, I'm not really sure if I have this setup properly or not. This is my first attempt at utilizing LINQ and I am trying to return data directly from an XML file.Here is my XML structure:

<folder_list>
<folder lbl="_localhost" abs="C:\_localhostapache2triadhtdocs" unc="C:\_localhostapache2triadhtdocs" tag="default" />
<folder lbl="Programming" abs="D:\_prog" unc="D:\_prog" tag="default" />
<folder lbl="Anime" abs="D:Anime" unc="D:Anime" tag="default" />

[Code]...

View 9 Replies

VS 2008 LINQ When Some Elements 'could' Be Missing?

Jan 27, 2010

some of the xelements within the query were calling for tags that didn't exist in the original xml, heres a simple example of what i mean.

element = _
<xml>
<object>
<string>someString</string>

[code]....

So how do i change the querry so that it wont produce a null error if the tags asked for are not present.

View 7 Replies

VS 2008 Make LINQ Strings?

Feb 4, 2010

q1/ how can i convert a lowercase string to sentence case with LINQ, without losing my rtb formatting?

View 2 Replies

VS 2008 Translate C# Linq Expression?

Nov 28, 2010

translation of the following C# Linq Expression (in VB.NET 2008):

syncContext.Send((obj) => eventToBeFired(this, new EventArgs()), null);

Is used in this subroutine:

private void FireEvent(EventHandler eventToBeFired)
{
if (eventToBeFired != null)
{

[code]....

View 3 Replies

VS 2008 Using LINQ With Collections And Strict On?

Mar 20, 2009

I've been having this niggling issue that's been driving me nuts. Maybe there's something I'm not doing quite right, I don't know. I'm hoping someone with more experience on the subject can show me a better way or just confirm this with a "Jenner, you're not nuts, that's just the way you need to do it".The problem is this. Every time I try to use LINQ to enumerate a Collection, and for this example, I'll use a Collection of TreeNodes in a TreeView control; I get an error of:

Option Strict On disallows implicit conversions from 'Object' to 'System.Windows.Forms.Treenode'.
for the following

[code].....

View 3 Replies

[2008] LINQ - Xml Elements Into A Datagridview?

Oct 20, 2009

I've become undone when trying to convert xml linq query result to a datagridview (see code below), needing some pointers,.

Dim doc As XDocument
doc = XDocument.Load("C: empxmltest.xml")
Dim query = From c In doc.<quotefile>.<quote> _

[code].....

View 3 Replies

Linq To Sql Query Using 2008 Express Edition

Jan 4, 2011

I encountered something like a logical error which I could hardly resolve since I'm new to this technology. I'm using visual basic 2008 express edition with its built-in linq-to-sql technology. I was able to retrieve, add, edit, and delete such record using the linq-to-sql method, but one thing.I could not get is something like relational database operation. Here is my problem. As you can see the table above which represents the records on my database. You can notice there some account numbers that were duplicated which I used as the primary key or identifier. What I want is when I'd like to query such account number it should display all the records that have the same account numbers on it. Say for example, if I query the account number 00003. It should only pull up and display three records with the name Maverick and their corresponding address, movie rented and date.What is happening in my end is when I query such account number which are being duplicated in the database I encountered two things, its either it would display all the records in the database with different account numbers associated or it gives me an error message if I change my code from 'For Each memrec In db.Table3s' to 'For Each memrec In retrn' statement.What I've been trying to do here is if you enter the account number on the search box, it should only display the records on the combo box associated with the account number being entered. Like if you enter 00003 on the search box, it should only display the three movies rented by Maverick no more no less on the combo box. [code]

I have already tried that set of codes before but it's working the same thing. I tried many times modifying my codes before I posted my comment in this forum thinking that i can resolve it on my own but I wasn't able to. That code won't still filter the records in the database. I would like to verify that the table above is only representation but the real column on the table on my database is 'Account#' not Account Number and visual basic would detect the code as 'Account_'. May i know why Movies_Rented column on my table is not a member of string? Why is it the code you gave would still display all the records on the combo box? this is what im not getting. hope you can still find the solution to this issue.

View 1 Replies

VS 2008 - Parsing Large XML File Using LINQ

Dec 27, 2010

I have one large XML file from one of our vendor and I am trying to pars it using Linq but it looks some wrong logic I am using.

This is xml file:
HTML
<Psw xmlns="http://localhost">
<exid>20</exid>
<Mes><Me>
<doc><ps>
<ghder> .....

The code I am trying:
Dim doc As XDocument
doc = XDocument.Load(TextBox1.Text)
Dim qList = (From xe In doc.Descendants.Elements("ghder") _
Select New With { _
.mid = xe.Element("MId").Value, _
.cdate = xe.Element("cD").Value _
' As well I need to get the value for pn child attribute }).FirstOrDefault
MsgBox(qList.mid)

Error for DBNull ' Object reference not set to an instance of an object.

View 6 Replies

VS 2008 : Get Fullnames From List (of String) Using LINQ?

Oct 18, 2010

I have this vb code in my asp.net webservice.

<WebMethod()> _
Public Function GetUsers(ByVal prefixText As String, ByVal count As Integer) As String()
Dim UsersList As New List(Of String)

[code]....

However, This returns all the users from my user table. I want to get just the users where the fullname is like the prefixtext variable that is passed in to the function.Now I need to use LINQ(the only way I can think of). But how do I change my code.

View 9 Replies

VS 2008 Convert A String Into A Linq Query?

May 20, 2012

Is there a way to convert a string into a linq query? Searching for those words brings up tons of stuff unrelated to what I'm trying to do..For instance, this works, of course...

Dim lstMyQuery = (From item in htMyTable.values where item(0) = "Apple" Select item)

But somehow I want to do this:

Dim strQuery = "From item in htMyTable.values where item(0) = " & CHR(34) & "Apples" & CHR(34) & " Select item"
Dim lstMyQuery = (Somehow run/convert strQuery as a query)

The reason is strQuery will be different each time depending on what the user has selected earlier in the program.R if lstMyQuery is already a collection, is there a way to add to it?

Dim lstMyQuery = (From item in htMyTable.values where item(0) = "Apples" Select item)

(this obviously doesn't work, but it's basically what I want to do...)

lstMyQuery.Add(From item in htMyTable.values where item(0) = "Oranges" Select item)

View 3 Replies

VS 2008 Data Not Updated Using LINQ + Sql 2000

Dec 28, 2010

[Code]...

I have the following records in the table student(see in fig 1). I am trying to update the Name of student whose Roll no =1. But Record is not updated in the database,

View 2 Replies

VS 2008 Datatable To Class Object Using LINQ

Sep 29, 2011

I have a datatable being returned by my DAL. In my BAL I want to return a class object. So I have a class called BusinessArea that has ID, Description and Active properties. I tried this:

[Code]...

View 2 Replies

VS 2008 How To Pass A LINQ Query To A Sub And Filter It

Feb 6, 2010

I have a LINQ query:[code]How can I pass "MyField" to the Sub and make the LINQ "Where" clause work?

View 2 Replies

VS 2008 How To Work With Multiple Updates By Linq To Sql

Oct 19, 2009

I would like to ask if it is possible to do a multiple records editing by linqtosql method in one click event? What I've been trying to do is to edit all the names in the table which are having the same account number. I was able to edit but only one name has been edited and the rest are not

******************************************************
Private Sub Button2_Click(------------) Handles Button2.Click
Dim accnt As String
accnt = Textbox1.Text

[Code]....

Why is it these codes could only edit records in one datarow? Can you debug the codes to edit all records which are having the same account number after it is being query?if that is possible for you.

View 3 Replies







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