We share a single poco's with
- ServiceStack WebServices
- ServiceStack Orm with MySQL
- Xamarin mobile client that uses Sqlite.net.
Problem is the shared classes have become a mess.
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
#if __MOBILE__
[Indexed]
#else
[Index]
#endif
public string UserAccountId { get; set; }
#if __MOBILE__
[Indexed]
#else
[Index]
#endif
And if it's not bad enough already, i need to
- Constrain the length of each field in the database....
- Save these objects in MongoDb. Fortunately, they have an AutoMapper class that does this at runtime.
Not sure what to do. My Failed ideas include:
Try to use: [Conditional("DEBUG")]. But it does nothing for this
It appears that sqlite.net uses its own attribute
[AttributeUsage (AttributeTargets.Property)] public class IndexedAttribute : Attribute
So it won't find the Mysql [Index] attribute
Could try to include two attributes on each property
[Indexed] [Index] public string UserAccountId { get; set; }
I tried to turn it into a two one line'ers but c# VS complains
#if __MOBILE__ [Indexed] #endif #if __MOBILE__ [Index] #endif
In the end, the only approach that ** APPEARS ** will work is to just keep the interface as the single definition of the class and have many concrete classes that get decorated differently.
Any Ideas??