2 Commits

Author SHA1 Message Date
Railz
64c8711754 Set version 2019-05-09 08:02:49 +02:00
Railz
ad3c1da0cd Fixes:
- Fields not matching
- FieldType being lookedUp wrong
- dictionary-access-violation
- guid saved as string not casting
- InsertQuery built wrong
2019-05-08 23:22:20 +02:00
5 changed files with 13 additions and 11 deletions

View File

@@ -30,7 +30,7 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System.Attributes
{ {
this.parentField = fi; this.parentField = fi;
this.classAttribute = classAttribute; this.classAttribute = classAttribute;
this.foreignObjectType = fi.GetType(); this.foreignObjectType = fi.FieldType;
// Init foreign-object class // Init foreign-object class
DbObject foreignClassAttribute = ClassAction.Init(this.foreignObjectType); DbObject foreignClassAttribute = ClassAction.Init(this.foreignObjectType);
@@ -45,7 +45,7 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System.Attributes
if(this._foreignKeyName != null) // If i have a name if(this._foreignKeyName != null) // If i have a name
{ {
// check if name matches // check if name matches
if (foreignKey.parentField.Name.ToLower() == this._foreignKeyName) if (foreignKey.parentField.Name.ToLower() == this._foreignKeyName.ToLower())
{ {
if(foreignKey.parentField.GetType() == primaryKeyType) if(foreignKey.parentField.GetType() == primaryKeyType)
{ {

View File

@@ -60,7 +60,10 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System
// 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())
{ {
baseAttribute.parentField.SetValue(classObject, 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
baseAttribute.parentField.SetValue(classObject, value);
break; break;
} }
} }

View File

@@ -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.7</Version> <Version>1.5.8</Version>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@@ -181,14 +181,14 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System
if (attributes.Count != data.Count) throw new InvalidOperationException("Cannot generate SQL-Query. Attribute-count and data-count not equal."); if (attributes.Count != data.Count) throw new InvalidOperationException("Cannot generate SQL-Query. Attribute-count and data-count not equal.");
string attributesSeperatedByComma = ""; string attributesSeperatedByComma = "";
object[] attributeData = new object[attributes.Count*2]; object[] attributeData = new object[attributes.Count*2 -1];
int c = 0; int c = 0;
for(int i=0; i<attributes.Count*2; i+=2) for(int i=0; i< attributes.Count; i++)
{ {
attributesSeperatedByComma += attributes[i]; attributesSeperatedByComma += attributes[i];
attributeData[c] = data[i+1]; attributeData[c] = data[i];
if(c+1 != attributes.Count*2) if(c+1 != attributeData.Length)
{ {
attributesSeperatedByComma += ", "; attributesSeperatedByComma += ", ";
attributeData[c+1] = ","; attributeData[c+1] = ",";

View File

@@ -79,6 +79,7 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System
{ {
// Read dbObject-attribute // Read dbObject-attribute
DbObject dbObject = ClassAction.Init(classType); DbObject dbObject = ClassAction.Init(classType);
Dictionary<string, object> convertedAttributeNameAndValues = new Dictionary<string, object>();
foreach (KeyValuePair<string, object> attributeNameAndValue in attributeNameAndValues) foreach (KeyValuePair<string, object> attributeNameAndValue in attributeNameAndValues)
{ {
@@ -87,9 +88,7 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System
{ {
if (attributeNameAndValue.Key.ToLower() == baseAttribute.parentField.Name.ToLower()) if (attributeNameAndValue.Key.ToLower() == baseAttribute.parentField.Name.ToLower())
{ {
attributeNameAndValues.Remove(attributeNameAndValue.Key); convertedAttributeNameAndValues.Add(baseAttribute._attributeName, attributeNameAndValue.Value);
attributeNameAndValues.Add(baseAttribute._attributeName, attributeNameAndValue.Value);
nameFound = true; nameFound = true;
break; break;