Added DbForeignObject for automatic resolving

Added Init() to initialise necessary classes
Changed structure and added a BaseAttribute
Fixed occuring errors to match new system
This commit is contained in:
Railz
2019-04-10 22:40:36 +02:00
parent 9253d77236
commit 85495af97f
11 changed files with 353 additions and 248 deletions

View File

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
namespace eu.railduction.netcore.dll.Database_Attribute_System.Attributes
{
[AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)]
public class DbPrimaryKey : BaseAttribute
{
/// <summary>
/// Marks variable as primaryKey fo current class
/// </summary>
/// <param name="dbAttributeName">Name of database-attribute (case-sensitivity is determined from database-attribute-settings) ['null' if the same as field-name]</param>
public DbPrimaryKey(string attributeName = null)
{
this._attributeName = attributeName; // Todo: Automatic resolving of name if it is null (?)
}
public void Init(FieldInfo fi, DbObject classAttribute)
{
this.parentField = fi;
this.classAttribute = classAttribute;
this._attributeName = this._attributeName ?? fi.Name; // If no alternative attribute-name is specified, use the property-name
}
}
}