Solved

Linq to SQL: object.Tolist manipulation not possible

Posted on 2008-10-01
2
597 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
  • 2
2 Comments
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 250 total points
Comment Utility
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 62

Expert Comment

by:Fernando Soto
Comment Utility
Hi stoffel_cc;

have you tried my solution?

Fernando
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now