Home > Software Development > WCF, Linq To Sql and SQL Image Type

WCF, Linq To Sql and SQL Image Type

Today I’m working on an endpoint for a Northwind demo.  The endpoint is UpdateEmployee and the problem I’m running into is that the Employee Table in Northwind has a field called Photo defined as an Image.
 
Since the constructor for System.Data.Linq.Binary can take a Byte[], I created my data contract as follows.
 

[DataContract(Name = "Employee")]

public class Employee

{

private

int? _employeeId;;

private

byte[] _photo;

[

DataMember(IsRequired = false, Name = "Photo", Order = 70)]

[

DataMember(IsRequired = false, Name = "EmployeeId", Order = 0)]

public int? EmployeeId

{

get { return _employeeId; }

set { _employeeId = value; }

}

public byte[] Photo

{

get { return _photo; }

set { _photo = value; }

}

Then in my CRUD function

if (employee.Photo != null && employee.Photo.Length > 0)

{

dalEmployee.Photo =

new System.Data.Linq.Binary(employee.Photo);

}

There are some other things I’m sure I’m going to have to account for but this should be a good starting point for anybody having trouble.

Advertisements
Categories: Software Development
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: