Now we are going to create a app where we would insert data to the database.
I will take up the same project again and add a new page to it.


I create a Data Model now as shown below:

Give it a Build now . Create a new Domain Service class as shown below:


namespace
SL2wayWCFRia.Web
{
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;
// Implements application logic using the
PublishingCompanyEntities context.
// TODO: Add your application logic to
these methods or in additional methods.
// TODO: Wire up authentication (Windows/ASP.NET
Forms) and uncomment the following to disable anonymous access
// Also consider adding roles to restrict
access as appropriate.
// [RequiresAuthentication]
[EnableClientAccess()]
public class
DataDomainService :
LinqToEntitiesDomainService<PublishingCompanyEntities>
{
// TODO:
// Consider constraining the results of
your query method. If you need additional input you can
// add parameters to this method or
create additional query methods with different names.
// To support paging you will need to
add ordering to the 'Articles' query.
public
IQueryable<Article>
GetArticles()
{
return this.ObjectContext.Articles;
}
public void
InsertArticle(Article article)
{
if ((article.EntityState !=
EntityState.Detached))
{
this.ObjectContext.ObjectStateManager.ChangeObjectState(article,
EntityState.Added);
}
else
{
this.ObjectContext.Articles.AddObject(article);
}
}
public void
UpdateArticle(Article currentArticle)
{
this.ObjectContext.Articles.AttachAsModified(currentArticle,
this.ChangeSet.GetOriginal(currentArticle));
}









yonathan BenitahPosted Nov 29, 2012, 11:23 AM
Hi, I have the following architecture: DB - DAL - BL - webService - Aspx I would like to add a new client (Silverlight app), but don't want it to depend on the aspx (only being hosted by the aspx). Also, i would like to use the RIAservice. Have you got an issue for me? Thx....
RicardoPosted Aug 25, 2011, 1:59 AM
Dear Mahadesh, First of all, thank you for this article (series of articles) about wcf ria services with silverlight. I've been struggling with it for quite a while untill now. But in your code when you create a new article you say art.ID = 101; And when you retrieve it with SQL from the database you say WHERE ArticleID = 20 This has to be a typo, or have you used a database table with identity specification on the ArticleID column? If that's so, the code has to break because you can't assign the ArticleID, or am I wrong? Please give me some clearity about this. Kind regards, Ricardo