views:

1900

answers:

2

Hi

I tried to use SubSunsonic.ActiveRecord in SL3 project that uses .NET RIA Services. However when I try to return some IQuerable in DomainService class I get an error that the classes generated by Subsonic have a property 'Columns' with an unsupported type. That's what I have

public IEnumerable<SE_NorthWind.SuperEmployee> GetIntegers()
{
  return SE_NorthWind.SuperEmployee.All()
    .Where(emp => emp.Issues > 100)
    .OrderBy(emp => emp.EmployeeID);
}

And this is the error I get

Error   7 Entity 'SE_NorthWind.SuperEmployee' has a property 'Columns' with an unsupported type. SuperEmployee

Any idea what to do? Don't really wanna use Linq to SQL :)

Thx

P.S. Just tried to LinqTemplates from SubSonic, but this solution I get the error

Error   4 The entity 'SE_NorthWind.SuperEmployee' does not have a key defined. Entities exposed by DomainService operations must have must have at least one property marked with the KeyAttribute. SuperEmployee

of course SuperEmployee table has a primary key, cause the classes generated by SubSonic can see it

...
Columns.Add(new DatabaseColumn("EmployeeID", this)
            {
                IsPrimaryKey = true,
                DataType = DbType.Int32,
                IsNullable = false,
                AutoIncrement = true,
                IsForeignKey = false,
                MaxLength = 0
            });
...

But RIA objects, they need some attributes. I guess I'll have to go with native Linq To SQL until SubSonic adapts to all this :(

A: 

To answer the second part of your question.

You need to add the "KeyAttribute" to the PrimaryKey property on the "EmployeeId" property. The attribute is in the "System.ComponentModel.DataAnnotations" namespace.

No up on Sub Sonic 3, but you could change the underlying template to generate this, or change the sub sonic engine and submit it as a patch.

I'm running with SilverLight 3 with RaiServices.

Hope this helps.

Binary Worrier
A: 

Can you try removing the [EnableClientAccess()] attribute to see if your project will build?

jdiaz