Asp.net - Serialize Linq Objects Not Working?

Apr 14, 2010

Using the following code:

Private Sub MakeMeSomeXmlBeforeRyanGetsAngry()
Dim db As New MyDBDataContext
Dim customer = From c In db.Customers Select c

[code]....

I am attempting to serialize my linq collection of customers. But it keeps throwing

Type 'System.Data.Linq.DataQuery`1[MyDB.Customer]' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. See the Microsoft .NET Framework documentation for other supported types. My issue is that I have already marked the dbml Serialization Mode to UniDirectional and when I check the dbml codebehind all of the DataContract()> and DataMember()> elements are there. I have tried adding various dataloadoptions and setting deferredloading to false, but no luck.

View 2 Replies


ADVERTISEMENT

Possible To Serialize Arraylist Of Objects Into xml?

Feb 27, 2009

Is it possible to serialize an arraylist of objects into xml?Its damn urgent.Kindly reply.

View 1 Replies

Multiple Classes For Serialize Objects?

May 9, 2009

I have one class with <Serialize> attribute called Tree. And Tree class has an arraylist of TreeNode classes. Is it possible to use Soap to convert the Tree class and arraylist of TreeNode classes to one xml file or binary file? If it is possible, do i need to use <Serialize> attribute on TreeNode classes too? If not, what should i do then?

View 3 Replies

C# - Serialize List Of Objects In Android And Deserialize In WCF?

Apr 17, 2012

I have an ArrayList in android that I'm trying to convert to a Base64 String, then passing that to a wcf service though JSON and the wcf service inserts the string into a database. Then I need to be able to read that from the database and deserialize it in a .NET application.

This is how I am serializing the ArrayList in android:

private String convertByteArrayToSave(byte[] b){
if(b != null){
return Base64.encodeToString(b,0,b.length,Base64.DEFAULT);
}else{

[Code]...

The ultimate goal is to be able to be able to create a list of these shapes in the .NET app or android app and be able to read the list in the .NET app and android app no matter where it was created from. I'm able to it when you create the Shape from .NET and read it into android using WCF but creating it in android.

View 1 Replies

Use ISerializable Interface To Serialize An Arraylist Of Objects?

May 10, 2009

I have a class called Tree, it has an arraylist called alTreeNodes. alTreeNodes is an arraylist of TreeNode class. Since I am using ISerializable Interface, I have to provide a specific constructor. I know how to write it for string parameters such as name_value, but how should i do with arraylist of object then? See "???" in the code blog before.

Protected Sub New(ByVal info As SerializationInfo, _
ByVal context As StreamingContext)
If info Is Nothing Then

[code]....

View 5 Replies

How To Manage Multiple DAT Files For Serialize Objects Of Same Class

Feb 13, 2010

How best to manage multiple dat files for serializable objects of the same class. If one of my data files goes past a particular size, I want to create a new file. I then loop through both files when I do processing. Is there any easier way to do this and what's the best size to do this at in terms of performance?

View 1 Replies

The New Serialize/Deserialize For Express 2010 Not Working?

Nov 4, 2010

Module ProjectSerializer

Sub Serialize(ByVal strPath As String, ByVal ProjInfo As ProjectInfo)
' create a filestream to allow saving the file after it has
' been serialized in this method

[code]....

View 7 Replies

VS 2008 Serialize A Class That Implements An Event That Don't Want To Serialize?

Aug 17, 2010

If a class is serialized and has events fired from it that are handled on a form you get the error "Form1 cannot be serialized" in c# you can use (to work around this):

[Code]....

View 1 Replies

C# - Where And When To Use LINQ To Objects

Feb 21, 2009

In which situations I should use LINQ to Objects?

Obviously I can do everything without LINQ. So in which operations LINQ to code shorter and/or more readable?

View 7 Replies

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 - String Where In LINQ To Objects

Jun 5, 2012

I have a linq query like that:

Elementos = From b In Elementos Where b.Value.IdGrupo = 0 Select b

"Elementos" is a dictionary(of long, MyObject). MyObject has approximately 50 properties.

The problem I have is that I have a new requirement to accept string parameter with a "where" condition. Something like "property1>10 and property2 like 'anystring' or property3<=25". (That means any property could have a condition. I have string and numeric properties.)

I'd like to keep using linq, adding the condition as it comes. I'm aware that it could produce an exception if the condition is misspelled or something, but that's acceptable (by try catchs). I wouldn't want to parse the string to build parameters or anything.

View 2 Replies

LINQ To XML And Child Objects?

Nov 20, 2009

I am creating a tool that interfaces with an API for a CD/DVD burner. I have created several custom classes that will hold the information for the disk sets (which consist of a data path and a label file among other information. The DiskSet class has a list of Include objects. My proposed XML output would be something similar to the following:

<DiskSets>
<DiskSet>
<Name>MySet 1</Name>

[code].....

I am attempting to traverse the Includes collection (I have tried List and Binding List as I am also using this in a pair of datagridview controls) and it keeps returning Expression of type 'Object is not queryable. Make sure you are not missing an assembly reference and/or namespace import for the LINQ provider." How can I use LINQ to pull a list of the Include objects under each DiskSet object for transformation into XML? I am hoping to keep this restricted to this one block of code if possible.

View 7 Replies

C# - Join The Objects In A LINQ Expression?

Dec 15, 2011

How to Join the objects in a LINQ select in this sample (C# variants accepted as well):

Class Room
Public Area As Integer
End Class
Class RoomPair

[code]....

View 4 Replies

C# - Linq To Objects Outer Join?

Mar 10, 2010

Im trying to use LINQ to query Objets. I'm doing the following:

Dim myList As Generic.List(Of MyItem) = (From ThisItem In LinqToSqlObject.Items _
Join Folder In LinqToSqlObject.Folders _
On Folder.Id Equals Item.Id _

[Code]....

This however will not return any item that has a ParentItemId of null. I am trying to do a left join so as to return all "Item" regardless of whether it has a parent or not. I am aware that this is feasible in C# by adding an "into X" on the join, and selecting from X.DefaultIfEmpty(), this however does not appear to work in VB.Net.

View 2 Replies

LINQ Filtering List Objects?

Mar 1, 2011

I have list object and I need to check id in a comma separated string using LINQ in VB.NET, something like this:

dim strId as String = "1,2,3,5,"
dim myList = from objmylist where objmylist.id in (strId)

View 4 Replies

LINQ To XML Syntax And Class Objects In .net?

Dec 10, 2010

I have the following XML file

<Test>
<Modules>
<Module Name= "Test1">
<QueueName Name="Test1Active1" Active="True"></QueueName>
<QueueName Name="Test1Active2" Active="True"></QueueName>

[Code]...

View 1 Replies

Linq-to-XML: Adding Enumerations To Objects?

Oct 2, 2010

I'm trying to figure out how to add an enumeration to an object with Linq. For example:

Dim thingBlock = <Things>
<Thing Name="Ish">
<SmallThing>Jibber</SmallThing>

[code].....

View 1 Replies

Working With Database And Objects?

May 16, 2010

Private Sub btnPurchase_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPurchase.Click
Dim objCustomer As Customer
Dim objProduct As Products
Try

[code]...

1- why not just write queries those manipulate the database rather then creating objects, making changes and then going back to database.

2- now that i have got the new balance and the product oder has been made so every time this happens a query has to be sent to change database or there is any other better why of doing it?

View 1 Replies

.net - LINQ Union Objects With Same Base Class?

Apr 5, 2011

I'm trying to create a list of all my objects from several lists of objects using Union.

Return Chart.AnnotativeNodes.Union( _
Chart.DecisionNodes.Union( _
Chart.EndNodes.Union( _
Chart.StartNodes.Union(Chart.WorkCenterNodes))))

The above line gets an error because I can't union List(of AnnotativeNode) with List(of DecisionNode). Each list defined like List(of EndNode) or List(of StartNode), but each class inherits from the base type Node.Is there a possible way to union these to get a result of IEnumerable(of Node)?

View 1 Replies

Asp.net - LINQ To Objects Auto-increment Number?

Feb 25, 2009

This feels like a completely basic question, but, for the life of me, I can't seem to work out an elegant solution.

Basically, I am doing a LINQ query creating a new object from the query. In the new object, I want to generate a auto-incremented number to allow me to keep a selection order for later use (named Iter in my example).

Here is my current solution that does what I need:

Dim query2 = From x As DictionaryEntry In MasterCalendarInstance _
Order By x.Key _
Select New With {.CalendarId = x.Key, .Iter = 0}

[Code]....

Is there a way to do this within the context of the LINQ query (so that I don't have to loop the collection after the query)?

View 3 Replies

Check If Objects Follow Sequentially Using LINQ?

May 27, 2011

I have an object that looks like follows:

Public Class MyObject
Public Property Key as Intger
get 'Elided for clarity

[code].....

View 2 Replies

Creating Objects From Child Elements Using LINQ To XML

Feb 1, 2011

Is there any way to use a LINQ to XML to query an XML document like the one below to create new (anonymous or strongly typed) objects from the child elements of a descendant? Here is my XML document:

[Code]...

View 2 Replies

Linq - Merge And Order 2 Lists Of Different Objects?

Mar 15, 2012

I have collections of 2 different types - let's call them Cars and Trucks. Both share base class Vehicle, which has property Passengers.I want to merge them into a single collection ordered by that property. E.g., merge Cars and Trucks and order by Passengers.

View 2 Replies

Linq To Entities Query With Child Objects?

Oct 13, 2011

Basically I have the follwing:Dim ctx As New AdminCoreEntities Dim roles = (From r In ctx.Roles where r.Name.StartsWith("cust") Select r) 'list of System .Linq.IQueryable(Of AdminCoreModel.Role)

[code]...

The error i get when i run this is: Unable to cast object of type System.Data.Objects.ObjectQuery`1[AdminCoreModel.Role] to type AdminCoreModel.Role

Basically I have a many to many situation and I try to get all the Quicklinks objects queried by their roles and not quite sure why EF will cast to a single AdminCoreModel.Role when i.Roles is a collections of objects.

View 1 Replies

LINQ To Objects, Query Arrays In Object?

Sep 15, 2011

I need to query an array. I have tried to use LINQ but with no success.

Here is a simplified structure of Insurance

Public Class Insurance
Public _typ As String
Public _numb As Number()

[Code]....

View 1 Replies

LINQ VB How To Check For Duplicates In A List Of Objects

Oct 11, 2011

I have a list of objects, each with 2 relevant properties: "ID" and "Name". Lets call the list "lstOutcomes".I need to check the list for duplicates (meaning object1.ID = object2.ID, etc.) and set a flag (valid = false, or something) if there is at least one duplicate. Also, it would be nice to send a message to the user mentioning the "Name" of the object, when it fails.I am sure I will need to use the Group By operator to do this, but I am not used to doing that in LINQ, and the examples out there are just not helping me. This article seems to be close to what i need, but not quite and it's in C#.

Here is a starting stab at it...
Dim duplist = _
(From o As objectType In lstOutcomes _

[code]......
help?

View 4 Replies

LINQ: Creating Objects Of Anonymous Types?

Oct 25, 2011

I am in the process of learning LINQ to Objects. I am querying an array of reference elements using LINQ. In the code below, which I have marked with asteriks and PROBLEM, I am having difficulty returning any values for and I suspect its because of the multiple Select arguments.

'Program name:Querying an Array of Invoice Objects
'Created/revised:
'Project description:To demonstrate the use of LINQ to query objects

[Code].....

View 4 Replies

Order By And Group By In A Linq To Objects Query?

Sep 28, 2010

How do I order by and group by in a Linq query?I tried..Dim iPerson = From lqPersons In objPersons Where Len(lqPersons.Person) > 0 Group lqPersons By key = lqPersons.Name Into Group Order By Group descending Select Group, key

For Each i In iPerson
tmp = tmp & vbNewLine & i.key & ", " & i.Group.Count
Next

[code].....

View 5 Replies

Querying An Array Of Invoice Objects (LINQ)?

Sep 19, 2009

I am having a little problem with some homework. Here is the problem:Use the Invoice Class provided to create an array of Invoice Objects. Class Invoice includes four properties- a PartNumber (type integer), a PartDescription (type String), a Quantity of the item being purchased (type Integer), and a Price (type Decimal). Write a Console Application that performs the following queries on the array of Invoice objects and displays the results:

[Code]...

View 3 Replies

.net - LINQ Query Returns List Of Empty Objects?

May 3, 2012

I have a query that 'selects' object of a type:

Dim l as IList(Of Foo) = (From dataRow As DataRow In table.Select()
Where CStr(dataRow("Column1")) = "A"
Select New Foo(CStr(dataRow("Column1")), _
CStr(dataRow("Column2")))).ToList()

What's happening is that if i set a break-point to the constructor of Foo and step, the constructor is hit and the parameters are loaded with the arguments. However, l has empty Foo objects (the members in every object are Nothing). What could be happening here?

View 1 Replies







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