Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d07d82ff5 | ||
|
|
b6bc82a766 | ||
|
|
3e8427c4c0 |
@@ -43,7 +43,6 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System
|
|||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
/// <param name="classObject">Given object (marked with Db-attributes)</param>
|
/// <param name="classObject">Given object (marked with Db-attributes)</param>
|
||||||
/// <param name="data">The data</param>
|
/// <param name="data">The data</param>
|
||||||
/// <param name="runDataLossChecks">This checks if any class-field and data-attribute does not exists in either (Slower)</param>
|
|
||||||
public static void FillObject<T>(T classObject, Dictionary<string, object> data)
|
public static void FillObject<T>(T classObject, Dictionary<string, object> data)
|
||||||
{
|
{
|
||||||
Type classType = classObject.GetType();
|
Type classType = classObject.GetType();
|
||||||
@@ -57,11 +56,19 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System
|
|||||||
// Interate through class-fields
|
// Interate through class-fields
|
||||||
foreach (BaseAttribute baseAttribute in dbObject.baseAttributes)
|
foreach (BaseAttribute baseAttribute in dbObject.baseAttributes)
|
||||||
{
|
{
|
||||||
|
// Remove any leading dots and table-specifiers
|
||||||
|
string dbAttName = data_keySet.Key;
|
||||||
|
if (dbAttName.Contains("."))
|
||||||
|
{
|
||||||
|
string[] dbAttNameSplit = dbAttName.Split('.'); // Split at the '.'
|
||||||
|
dbAttName = dbAttNameSplit[dbAttNameSplit.Length - 1]; // Copy the ending text
|
||||||
|
}
|
||||||
|
|
||||||
// If its a match, set the value
|
// If its a match, set the value
|
||||||
if (baseAttribute._attributeName.ToLower() == data_keySet.Key.ToLower())
|
if (baseAttribute._attributeName.ToLower() == data_keySet.Key.ToLower())
|
||||||
{
|
{
|
||||||
object value = data_keySet.Value;
|
object value = data_keySet.Value;
|
||||||
if (baseAttribute.parentField.FieldType == typeof(Guid)) value = new Guid((string)value); // If its a guid, i need to convert
|
//if (baseAttribute.parentField.FieldType == typeof(Guid)) value = new Guid((string)value); // If its a guid, i need to convert
|
||||||
|
|
||||||
baseAttribute.parentField.SetValue(classObject, value);
|
baseAttribute.parentField.SetValue(classObject, value);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||||
<RootNamespace>eu.railduction.netcore.dll.Database_Attribute_System</RootNamespace>
|
<RootNamespace>eu.railduction.netcore.dll.Database_Attribute_System</RootNamespace>
|
||||||
<SignAssembly>false</SignAssembly>
|
<SignAssembly>false</SignAssembly>
|
||||||
<Version>1.5.11</Version>
|
<Version>1.5.13</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Reference in New Issue
Block a user