Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
programming4us
Windows 7

Visual Basic 2010 : Serialization in the ADO.NET Entity Framework

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
6/14/2011 9:16:17 AM
When you create Entity Data Models, entities are automatically decorated with Serializable and DataContract attributes and their members as DataMember as you can easily check by investigating the code-behind file for EDMs. This enables binary and Xml serialization for entities also in WCF scenarios. To understand how this works, create a new console project and add a new EDM wrapping the Northwind database , including only the Customers and Orders tables. Basically you use formatters as you did in the objects serialization with no differences. Code in Listing 1 shows how to accomplish this.
Listing 1. Serializing Entities from an Entity Data Model
Imports System.Runtime.Serialization.Formatters.Binary
Imports System.IO

Module Module1
Sub Main()
Using northwind As New NorthwindEntities
'Retrieves the first order, as an example
Dim anOrder As Order = northwind.Orders.Include("Customer").First

'Same as classic objects serialization
Dim formatter As New BinaryFormatter
Using stream As New FileStream("C:\temp\EFSerialization.dat",
FileMode.Create)
formatter.Serialize(stream, anOrder)
End Using

Dim newOrder As Order
Using source As New FileStream("C:\temp\EFSerialization.dat",
FileMode.Open)
newOrder = CType(formatter.Deserialize(source), Order)
End Using
End Using

Console.ReadLine()
End Sub
End Module


Other -----------------
- Visual Basic 2010 : Serialization in Windows Communication Foundation
- Microsoft Excel 2010 : Creating and Modifying Charts - Selecting Chart Elements & Formatting Chart Elements
- Microsoft Excel 2010 : Creating and Modifying Charts - Changing a Chart Type & Changing a Chart Layout and Style
- Microsoft Visio 2010 : Serialization with XAML
- Microsoft Visio 2010 : Custom Serialization
- Microsoft Visio 2010 : Connecting Shapes with Dynamic Connectors
- Microsoft Visio 2010 : Copying and Pasting Shapes & Connecting Shapes with Lines
- Microsoft PowerPoint 2010 : Working Together on Office Documents - Creating Office Documents on Windows Live
- Microsoft PowerPoint 2010 : Working Together on Office Documents - Setting Folder Permissions on Windows Live
- Visual Basic 2010 : XML Serialization
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server