Ejemplo n.º 1
0
        public void PrepareProperties()
        {
            if (this.Properties != null)
            {
                return;
            }
            this.Properties = this.Model.GetType().GetProperties();
            foreach (var prop in this.Properties)
            {
                if (prop.Name.Equals("ID"))
                {
                    this.IdPropertyInfo = prop;
                }
            }

            PropertySignatures = new List <DirectModelPropertySignature>();
            for (int i = 0; i < this.Properties.Length; i++)
            {
                if (!IgnoredPropertyNames.Contains(this.Properties[i].Name))
                {
                    var signature = new DirectModelPropertySignature(this.Properties[i]);
                    if (signature.IsPrimary)
                    {
                        this.IdPropertyInfo = this.Properties[i];
                        if (Properties[i].PropertyType == typeof(string))
                        {
                            this.Model.IntegerPrimary = false;
                            Properties[i].SetValue(this.Model, this.Model.InternalID);
                        }
                    }
                    PropertySignatures.Add(signature);
                }
            }
        }
Ejemplo n.º 2
0
    internal string GetValue(DirectModelPropertySignature signature)
    {
      var val = Model.GetType().GetProperty(signature.PropertyName).GetValue(this.Model, null);

      // override nullable strings
      if (val != null && Model.GetType().GetProperty(signature.PropertyName).PropertyType == typeof(string) && string.IsNullOrEmpty(val.ToString()) && signature.Nullable)
        return "NULL";

      return val == null ? "NULL" : val.ToString();
    }