?
Solved

Linq to SQL: object.Tolist manipulation not possible

Posted on 2008-10-01
2
Medium Priority
?
603 Views
Last Modified: 2013-11-11
When I try to work with the returned list from the query i can't change it's property
While the class has a get and set property

even when i create a copy i cant change the polygon property is there a way to create a copy without the readonly property.

so i can use the changed data further in my code

Thanks in advance
===========APPLICATION CODE============
=======================================
 Dim cityList = (From c In cities _
        Select c.name, c.polygon).Take(100).ToList
 
        Try
        Dim point As New ArrayList()
        '..... some manipulation                
        cityList(i).polygon = point
        Catch ex As Exception
 
        End Try
 
 
 
 
======================================
===========MAPPING CLASS==============
======================================
<Column(Storage:="_polygon", AutoSync:=AutoSync.Always, DbType:="NVarChar(MAX)", IsDbGenerated:=true, UpdateCheck:=UpdateCheck.Never)>  _
	Public Property polygon() As String
		Get
			Return Me._polygon
		End Get
		Set
			If (String.Equals(Me._polygon, value) = false) Then
				Me.OnpolygonChanging(value)
				Me.SendPropertyChanging
				Me._polygon = value
				Me.SendPropertyChanged("polygon")
				Me.OnpolygonChanged
			End If
		End Set
	End Property

Open in new window

0
Comment
Question by:stoffel_cc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 1000 total points
ID: 22617190
Hi stoffel_cc;

When you declare the query as you did and make the Select clause with just the two properties, the Select clause make the Anonymous type Read-Only

Dim cityList = (From c In cities _
                Select c.name, c.polygon).Take(100).ToList

When you make the Select clause as in the following the properties are now read/write

Dim cityList = (From c In cities _
                Select New With { c.name, c.polygon }).Take(100).ToList

In the following Select Clause the property with the key word Key is Read-Only whilw the other is read/write

Dim cityList = (From c In cities _
                Select New With { c.name, Key c.polygon }).Take(100).ToList

Fernando

0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 22624471
Hi stoffel_cc;

have you tried my solution?

Fernando
0

Featured Post

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question