DB ORM

Graham Fawcett fawcett at uwindsor.ca
Thu Aug 11 06:18:08 PDT 2011


On Thu, 11 Aug 2011 20:10:15 +0800, zhang wrote:

>> > I think D needs user defined attributes first.
> 
> About attribute, here is an example:
> 
> ....
>
> There is a problem that is D's basic type is not nullable. In C#,
> the nullable integer type can be defined as "Int?" or
> "Nullable<int>".

You don't need attributes for that: you can just define a "struct
Nullable(T)" that wraps the value, and provides a way to express a
null value.

    struct Person {
      int ID;           // required
      Nullable!int age; // optional
      ...
    }

    void foo(Person p) {
      if (p.age.isNull) ...
      else writeln(p.age + 100); 
    }

Graham


More information about the Digitalmars-d mailing list