internal WritableTableDefinition()
        {
            TableType = typeof(T);
            TableName = TableType
                        .GetCustomAttribute <DALTable>()?.TableName?.MySqlObjectQuote()
                        ??
                        throw new CustomAttributeFormatException(DatabaseCoreUtilities.NoDalTableAttributeError);

            //TODO: check if table exists and either truncate or drop as necessary

            var resolvableProperties = TableType
                                       .GetProperties()
                                       .Where(x => x.GetCustomAttribute <DALResolvable>() != null);

            if (resolvableProperties.Count() == 0)
            {
                throw new CustomAttributeFormatException(DatabaseCoreUtilities.NoDalPropertyAttributeError);
            }

            // get properties from object, convert to underscore names
            TableProperties = UnderscoreNamesHelper
                              .ConvertPropertiesToUnderscoreNames(TableType, ForceLowerCase: true, GetOnlyDalResolvables: true)
                              .Select(x => new DALPropertyType(x.Value.Item2.PropertyType)
            {
                ColumnName              = x.Key.MySqlObjectQuote(),
                PropertyName            = x.Value.Item1,
                PropertyTypeInformation = x.Value.Item2,
                ResolvableSettings      = x.Value.Item2.GetCustomAttribute <DALResolvable>()
            });
        }
Exemple #2
0
 /// <summary>
 /// Gets the full info about the current object's properties, including the underscore names.
 /// </summary>
 /// <param name="GetOnlyDbResolvables">Indicate to get only properties marked with the DALResolvable attribute.</param>
 /// <returns>The full list of property info including underscore names.</returns>
 public List <KeyValuePair <string, Tuple <string, PropertyInfo> > > GetUnderscoreProperties(bool GetOnlyDbResolvables = true)
 {
     return(UnderscoreNamesHelper.ConvertPropertiesToUnderscoreNames(this.GetType(), GetOnlyDalResolvables: GetOnlyDbResolvables));
 }