Visual Studio 2013 and Ria Services

Fully supported apparently… But don’t expect the Domain Services Template to be there anymore. So I took my trivial implementation from 2012, and moved it across to 2013, and from there I can make it the basis of a CRUD template. This then is the starting point:


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Linq;
using System.ServiceModel.DomainServices.EntityFramework;
using System.ServiceModel.DomainServices.Hosting;
using System.ServiceModel.DomainServices.Server;

namespace SilverlightApplication1.Web
{

[EnableClientAccess()]
public class MyDomainService : LinqToEntitiesDomainService
{

public IQueryable GetCustomers()
{
return this.ObjectContext.Customers;
}

public void InsertCustomer(Customer customer)
{
if ((customer.EntityState != EntityState.Detached))
{
this.ObjectContext.ObjectStateManager.ChangeObjectState(customer, EntityState.Added);
}
else
{
this.ObjectContext.Customers.AddObject(customer);
}
}

public void UpdateCustomer(Customer currentCustomer)
{
this.ObjectContext.Customers.AttachAsModified(currentCustomer, this.ChangeSet.GetOriginal(currentCustomer));
}

public void DeleteCustomer(Customer customer)
{
if ((customer.EntityState != EntityState.Detached))
{
this.ObjectContext.ObjectStateManager.ChangeObjectState(customer, EntityState.Deleted);
}
else
{
this.ObjectContext.Customers.Attach(customer);
this.ObjectContext.Customers.DeleteObject(customer);
}
}
}
}

Hm, no cigar just yet: you have to grab the references for these libraries, which are evidently (prove me wrong please) part of VS 2013:

using System.ServiceModel.DomainServices.EntityFramework;
using System.ServiceModel.DomainServices.Hosting;
using System.ServiceModel.DomainServices.Server;

, and I’m still getting errors, presumably because because its DBContext now? As I used EF5.0? (eg no EntityState, ObjectStateManager, AddObject, ChangeSet, DeleteObject).

So more work needed – I need to Nuget EF4.0 I guess.

Stick with it.

Advertisements

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