OData support

May 24, 2010 at 4:04 PM
I've extended L2ST4 with OData support i.e. adding DataServiceKey attribute for primarykeys and IgnoreProperties attribute for Enums. Should I submit a patch? I guess one could add the full IUpdateable implementation for L2S as well (http://code.msdn.microsoft.com/IUpdateableLinqToSql)
Coordinator
May 26, 2010 at 2:46 AM

It could be an interesting addition although I can't accept actual code patches - how much noise does it add to the template?  I'd need to implement the code myself to keep legal happy :(

[)amien

May 26, 2010 at 8:14 AM
oh, that's unfortunate. Actually it's quite easy, add the [System.Data.Services.Common.DataServiceKey("Id")] attribute to each class, and add every PrimaryKey as arguments to it. If you, as I have, applied xslt transformation to the dbml and replaced some columns with Enums you have to exclude those: [System.Data.Services.IgnoreProperties("MyEnum")] i check this by <# if (class1.Columns.Any(c => c.Type.IsAssignableFrom(typeof(Enum)))) {#>
May 26, 2010 at 8:23 AM
actually the OData's inability to handle enums is quite crippling. if one ignore all his enums a lot of essential information is lost, so i guess this ain't a good solution. and i don't think it's that common that you do transform you dbml and insert enums, so you can skip that part. just adding the DataServiceKey attribute should be fine.