8/20/2013 First glimpse of DomainController

Categories: Open RIA Services, Project Lead, General Other articles by:ColinBlair Colin Blair

We are still waiting for the code to be released by Microsoft, but in the meantime I thought I would post up an extremly preliminary idea of what the DomainController might look like. In this case, it is the DbDomainController:

public class AddressBookDomainController : DbDomainController<AddressBookContext> 
  protected override void OnDomainCreating(DbDomainBuilder<AddressBookContext> domainBuilder) 
  
    domainBuilder.Repositories.Add<AddressRepository>()
      .RequiresRole(OperationType.All, "AddressEditor")
      .RequiresRole(OperationType.Read, "ContactViewer"); 
    domainBuilder.Repositories.Add<PersonRepository>()
      .RequiresRole(OperationType.All, "PersonEditor")
      .RequiresRole(OperationType.Read, "ContactViewer"); 
    }     
}

The DomainController can look just like the DomainService does with all of the individual CRUD methods in the body, but you will also be able to register repositories with the DomainController and have the CRUD methods picked up from the repository. This is what the repository would look like:

public class PersonRepository 
  AddressBookContext Context {get;set;} 
  public PersonRepository(AddressBookContext context) 
  
    Context = context; 
  
  public IQueryable<Person> GetPeople 
  
    return Context.Persons; 
  
  public void InsertPerson(Person entity) 
  
    DbEntityEntry<LoadRating> entityEntry = this.Context.Entry(entity); 
    if ((entityEntry.State != EntityState.Detached)) 
    
      entityEntry.State = EntityState.Added; 
    
    else
    
      this.Context.People.Add(entity); 
    
  
  public void UpdatePerson(Person currentPerson) 
  
    this.Context.People.AttachAsModified(currentPerson, this.Context); 
  
  public void DeletePerson(Person entity) 
  
    DbEntityEntry<Person> entityEntry = this.Context.Entry(entity); 
    if ((entityEntry.State != EntityState.Detached)) 
    
      entityEntry.State = EntityState.Deleted; 
    
    else
    
      this.Context.People.Attach(entity); 
      this.Context.People.Remove(entity); 
    
  
}


This content has not been rated yet. 

Comments

rfrick

rfrick

This looks interesting...Still no code from MS? :)

9/11/2013 1:08:26 PM

Josef

Surely, you've got the source code by now?

I know, I know, "don't call me Shirley..."

Please let us know if there's anyone we can "pester" to get the code release to happen sooner than later.

9/23/2013 7:42:59 PM
ColinBlair

Colin Blair

When the code is handed over it will be on Codeplex (https://openriaservices.codeplex.com/SourceControl/latest). There will be a brief period where I am cleaning the code up (namespaces, etc). Following that is when Outercurve officially announces the project open. If you want to be the first-ish to know, watch the source control on codeplex, check the history "when" the code appears, and the official announcement should follow soon after that.

9/23/2013 9:02:46 PM
Gatolus

Gatolus

I see code... :) https://openriaservices.codeplex.com/SourceControl/latest

:)

9/28/2013 5:13:32 PM
rfrick

rfrick

Excellent news!

9/28/2013 6:18:09 PM
Notify me when new comments are added to this post
Save comment