Update List With Linq Instead Of For Each?
Mar 9, 2012
I 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]....
View 2 Replies
ADVERTISEMENT
Nov 5, 2010
Public Sub UpdateStaff(ByVal sr As StaffRecord)
Dim oldSr As StaffRecord
Dim q = From staff In db.StaffRecords Where staff.Employee_Number = sr.Employee_Number Select staff
oldSr = q.First
oldSr.Address_Line1 = sr.Address_Line1
[Code]...
The helper function I have written seems to do everything I want apart from update the db. Stepping through the code, the oldSr is updated by the new sr parameter but no update on submit changes.
View 2 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
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
Dec 22, 2010
I have 2 classes
Public Class Shipper
Public Property ShipperID As Long
Public Property CreateDate As DateTime
[Code].....
View 1 Replies
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
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
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
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
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
Sep 21, 2010
I think (?) this is about object design, and perhaps about structural and/or creational patterns. But a bit hard to say when I only know a couple of patterns yet.[code]But... what if we INSTEAD want each Product instance only to (in some way) refer to one instance of a specific list of Components. So we wan't to save the products list to one file, and the components list to another file. Then would I build the objects the same way, or different? So let's then say we have now Class B as below. [code]
1. Will not need to update each component variable of the products list when the components list changes.
2. If the Product object shall be shown in a DataGridView, for editing properties, it seems easier to implement the selection of the component property.
Is this wrong approach? Is it suitable in some cases, and if so, when? Are there other solutions I perhaps am not aware of that would be appropriate? Is this about structural design patterns? and if so, can the alternatives above be catagorized to some pattern type? I don't really know exactly what I'm looking for.. But I think probably I'm looking to understand whether the object design will be determined by the way the objects are saved.. And if i shall save the objects by serializing to file, vs saving to a database, would I create the business objects differently?
View 4 Replies
Nov 17, 2010
I'm playing around with Linq and XML and came across a need to update an XML node. Below is my code to read the xml, my question is, can I edit the xml source that I have loaded in to memory (from file) and save it?[cod]e...
View 1 Replies
Dec 17, 2010
Im trying to update the "value" Attribute of some xml file that have this structure:
<app-settings>
<setting name="codeBasePath" value="E:data" />
<setting name="server" value="LOCALHOST" />
[Code].....
View 6 Replies
Sep 21, 2010
discovered the compact mode of this instructions vs usual code. I found sample code for selecting, etc. from a datatable, transforming a column in a list or array - all operations are "Select"s - readonly.I need to make an simple update on a certain rows (using LINQ) from a DISCONNECTED datatable for which now I'm using this
for each dr as datarow in dtable.Rows
dr("MyField") = 77
next
[code].....
View 16 Replies
Aug 1, 2011
I need to update a datatable using LINQToSql. Option Strict is ON. Datatable name is Customer with fields customerID, customerName, SalesID. I need to update rows with SalesID = -1.
View 1 Replies
Mar 15, 2010
I'm editing XML element with the following XML:
<?xml version="1.0" encoding="utf-8"?>
<!--Test XML with LINQ to XML-->
<LabSerivceInfo><LabService>
<ServiceType>Copy</ServiceType>
<Price>1</Price></LabService>
[Code] .....
How to update the ServiceType and Price where ServiceType = varServiceType?
View 2 Replies
Mar 15, 2010
I'm trying to update an element in the XML document below:
Here's the code:
Dim xmldoc As XDocument = XDocument.Load(theXMLSource1)
Dim ql As XElement = (From ls In xmldoc.Elements("LabService") _
Where CType(ls.Element("ServiceType"), String).Equals("Scan") _
[code]....
But, I got this error message:
Object reference not set to an instance of an object.Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.Error line:ql.SetValue("23")
View 1 Replies
Aug 31, 2009
In general I have a xml document that i need to update.The query looks like this:
Of course it gives me a "This attribute is readonly" error.[code]...
View 4 Replies
Aug 18, 2010
Very simple update. It simply fails, no error, no change gets made to the database.Dim db As New BarClassesDataContext Dim foo = (From a In db.articles Where a.id = 14 Select a).Single Response.Write("<h3>" & foo.title & "</h3>") foo.title = "This is my new, updated title for article ID #14"
db.SubmitChanges()
Here is the relevent portion of my article class. Also, this is a web form so I have no console. Is there another way to view the T-SQL output?
<Table(Name:="dbo.article")> _
Partial Public Class article
Private _id As Integer
Private _issueid As Integer
Private _dateadded As Date
[Code]...
View 3 Replies
Apr 15, 2012
im pretty much a beginner to using ASP.net and linq to sql but what im trying to do is update a column of a table based on a variable. at the momment i have
Dim db As New sqldcDataContext Dim update As tableName = (From i in db.tableNames _ Select i)
i think this selects everything, how could i have two variables, one to store what table to update and the other what column. is this possible?edit: sorry for being unclear im trying to make this as dynamic as possible so i dont have to type in the exact table/col names. something like this but in the linq to sql syntax.
mysql_query("SELECT * FROM ". $table ." WHERE `" . $column . "` = "" . $data ."");
View 2 Replies
May 11, 2009
I use the following statement to position which row to update;
Dim salonToUpdate = (From r In db.Salons _
Where r.StoreID = storeID _
Select r).Single()
If fileDate = #1/1/1900# OrElse fileDate = Nothing Then
SalonToUpdate.LastDownLoadDate = TableDate
[Code] .....
I've double checked to make sure none of the dates are invalid or null, but when the bolded statement executes, the following sql runs through the trace:
exec sp_executesql N'UPDATE [dbo].[Salons]
SET [LastDownLoadDate] = @p0
WHERE 0 = 1',N'@p0 datetime',@p0='2008-01-04 00:00:00:000'
Of course it's going to fail if LINQ is passing in where 0=1 every time. Shouldn't it be using some unique row identifier, (in my case, the salon id), to update the specific row?
View 2 Replies
Jun 19, 2009
I am using database compact and i loaded it on my form and i want to update a single field but I cannot, why:
what am doing is:
dim newrec as datatable=(studentdataset."TableName")
dim querie= from det in newrec.asnumerable() _
[code].....
View 5 Replies
Aug 22, 2009
I use this command to retrieve information from an Access database:
Try
Dim result = From row In Me.ChitaDataSet1.chita.AsEnumerable() _
Where row.Field(Of String)("askID") = x _
Select row[code]....
how to Update a cell in specified row-coloumn coordinates?
View 9 Replies
Jul 31, 2011
Im using linq and im able get get data ouf of it realy easy. but i seem to not be able to update the data. the program does not error on it and it looks likes it has updated but it does not save te changes.
Public Function UpdateAlarmsbyKey(ByVal objKey As Integer, ByVal IdNumber As String) As Boolean
[Code]...
View 1 Replies
Apr 26, 2010
I have 2 tables Table1 with columns [BId,Name,Amount] Table2 with columns [CId,BId, ExpenseType,Expense]. BId Is the foreign key in Table2. The Amount field in Table1 is always higher than Expense in Table2. I need to update the values of Amount (increase or decrease) based on value of Expense and I want to do it in single query in LINQ. Eg If the Expense has to be updated with 200, I would decrease(negate) Amount value with 200. If Expense is reduce to 100 then the Amount is increased by a value of 100.
View 1 Replies
Aug 22, 2011
I´m trying to update my Students table record using LINQ to SQL. The problem is when one of the Properties of the object changed and 'PropertyChanging' Event is fired using 'SendPropertyChanging()' method.
student_id is a PK
data types are matched
Here is the full ArgumentException:
GenericArguments[2], 'System.String', on
'System.Data.Linq.Mapping.PropertyAccessor+Accessor`3[T,V,V2]'
violates the constraint of type 'V2'.
[code]....
View 1 Replies
Jul 12, 2011
I am pretty new to using LINQ and have been trying it out querying my strongly typed DataTable.
I have managed to perform a 'Select' ok but was wondering if someone can point me in the right direction to do Insert and Updates. I'm not sure if LINQ is best doing an insert at all?
My Select code is as follows:
Dim results = From myRow In _dt.AsEnumerable() _
Where myRow.Language_key = Lang And _
myRow.Section_key = SectionKey And _
[Code]....
View 1 Replies
May 4, 2012
[code]How do I update the ProdServiceID in the database using LINQ to entities?
View 1 Replies
Jun 22, 2011
How to update columns in datatable using linq without conditions. I have an idea that I'm just gonna loop all the data in the datatable but don't know what comes in LINQ.
View 5 Replies