{"action":"created","issue":{"url":"https://api.github.com/repos/Starcounter/Starcounter/issues/2480","labels_url":"https://api.github.com/repos/Starcounter/Starcounter/issues/2480/labels{/name}","comments_url":"https://api.github.com/repos/Starcounter/Starcounter/issues/2480/comments","events_url":"https://api.github.com/repos/Starcounter/Starcounter/issues/2480/events","html_url":"https://github.com/Starcounter/Starcounter/issues/2480","id":54296057,"number":2480,"title":"Regarding implementation of Entity.Type","user":{"login":"per-samuelsson","id":2902045,"avatar_url":"https://avatars.githubusercontent.com/u/2902045?v=3","gravatar_id":"","url":"https://api.github.com/users/per-samuelsson","html_url":"https://github.com/per-samuelsson","followers_url":"https://api.github.com/users/per-samuelsson/followers","following_url":"https://api.github.com/users/per-samuelsson/following{/other_user}","gists_url":"https://api.github.com/users/per-samuelsson/gists{/gist_id}","starred_url":"https://api.github.com/users/per-samuelsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/per-samuelsson/subscriptions","organizations_url":"https://api.github.com/users/per-samuelsson/orgs","repos_url":"https://api.github.com/users/per-samuelsson/repos","events_url":"https://api.github.com/users/per-samuelsson/events{/privacy}","received_events_url":"https://api.github.com/users/per-samuelsson/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Starcounter/Starcounter/labels/Code+host","name":"Code host","color":"009800"},{"url":"https://api.github.com/repos/Starcounter/Starcounter/labels/G%2FDynamicSchema","name":"G/DynamicSchema","color":"009800"},{"url":"https://api.github.com/repos/Starcounter/Starcounter/labels/question","name":"question","color":"02d7e1"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-01-14T08:32:04Z","updated_at":"2015-01-15T12:22:45Z","closed_at":null,"body":"Considering this https://github.com/Starcounter/Starcounter/issues/2473#issuecomment-69332832, we have established that any class that define a ```[Type]``` reference will trigger Starcounter to auto-assure such instance upon binding. This is implemented as part of #2477.\r\n\r\nHence,\r\n\r\n```C#\r\n[Database] public class Car {\r\n  [Type]\r\n  public CarModel Model;\r\n}\r\n\r\n[Database] public class CarModel {}\r\n\r\nclass Program {\r\n  static void Main() {\r\n    Console.WriteLine(new Car().Model == null);\r\n  }\r\n}\r\n```\r\n\r\nwill output **false**.\r\n\r\nThis brings up a few questions about what happens if ```Car``` instead derives ```Entity```. In ```Entity```, there is already a predfied ```[Type]``` property (named ```Type```), with the datatype ```Entity```.\r\n\r\nI assume this code\r\n\r\n```C#\r\npublic class Car : Entity {}\r\n\r\nclass Program {\r\n  static void Main() {\r\n    Console.WriteLine(new Car().Type == null);\r\n  }\r\n}\r\n```\r\n\r\nwill also output **false**. Can I get this confirmed to be absolutely sure?\r\n\r\nIf I'm right in the above, I can see the implementation of ```Entity.Type``` in various ways. Basically, the fall under two categories:\r\n\r\na) the ```Entity``` is instantiated and configured (e.g. ```IsType=true```, etc) on binding, just like ```CarModel```\r\nb) the ```Entity``` returned in the second sample is a runtime instance, \"wrapping\" and exposing the relevant Entity properties from the metadata tables (since all the info is there already).\r\n\r\nBoth type of solutions will require some work."},"comment":{"url":"https://api.github.com/repos/Starcounter/Starcounter/issues/comments/70078203","html_url":"https://github.com/Starcounter/Starcounter/issues/2480#issuecomment-70078203","issue_url":"https://api.github.com/repos/Starcounter/Starcounter/issues/2480","id":70078203,"user":{"login":"k-rus","id":1726044,"avatar_url":"https://avatars.githubusercontent.com/u/1726044?v=3","gravatar_id":"","url":"https://api.github.com/users/k-rus","html_url":"https://github.com/k-rus","followers_url":"https://api.github.com/users/k-rus/followers","following_url":"https://api.github.com/users/k-rus/following{/other_user}","gists_url":"https://api.github.com/users/k-rus/gists{/gist_id}","starred_url":"https://api.github.com/users/k-rus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/k-rus/subscriptions","organizations_url":"https://api.github.com/users/k-rus/orgs","repos_url":"https://api.github.com/users/k-rus/repos","events_url":"https://api.github.com/users/k-rus/events{/privacy}","received_events_url":"https://api.github.com/users/k-rus/received_events","type":"User","site_admin":false},"created_at":"2015-01-15T12:22:45Z","updated_at":"2015-01-15T12:22:45Z","body":"> since we are anyway planning to merge SystemEntity and Entity eventually.\r\n\r\nI fully support this!"}}