/// <summary> /// Copies the property. /// </summary> /// <param name="prop">The property.</param> public void CopyProperty(IManyToOneProperty prop) { if (prop is null) { return; } ManyToOneProperties.Add(prop.Convert <TClassType>(this)); }
/// <summary> /// Generates the query. /// </summary> /// <param name="queryObject">The object to generate the queries from.</param> /// <param name="property">The property.</param> /// <returns>The resulting query</returns> public override IQuery[] GenerateQueries(TMappedClass queryObject, IClassProperty property) { return(property switch { IMapProperty TempMapProperty => MapProperty(TempMapProperty, queryObject), IManyToManyProperty Property => ManyToManyProperty(Property, queryObject), IManyToOneListProperty ManyToOne => ManyToOneProperty(ManyToOne, queryObject), IManyToOneProperty ManyToOne => ManyToOneProperty(ManyToOne, queryObject), _ => Array.Empty <IQuery>(), });
/// <summary> /// Loads the list. /// </summary> /// <param name="returnValueName">Name of the return value.</param> /// <param name="builder">The builder.</param> /// <param name="property">The property.</param> private static void LoadList(string returnValueName, StringBuilder builder, IManyToOneProperty property) { builder.AppendLineFormat("if(!{0}&&!(Session0 is null))", property.InternalFieldName + "Loaded") .AppendLine("{") .AppendLineFormat("{0}=Session0.LoadProperties<{1},{2}>(this,\"{3}\");", property.InternalFieldName, property.ParentMapping.ObjectType.GetName(), property.TypeName, property.Name) .AppendLineFormat("{0}=true;", property.InternalFieldName + "Loaded") .AppendLineFormat("if(!({0} is null))", property.InternalFieldName) .AppendLine("{") .AppendLineFormat("((ObservableList<{1}>){0}).CollectionChanged += (x, y) => NotifyPropertyChanged0(\"{2}\");", property.InternalFieldName, property.TypeName, property.Name) .AppendLineFormat(@"((ObservableList<{1}>){0}).ForEach(TempObject => {{ ((IORMObject)TempObject).PropertyChanged += (x, y) => ((ObservableList<{1}>){0}).NotifyObjectChanged(x); }});", property.InternalFieldName, property.TypeName) .AppendLine("}") .AppendLine("}") .AppendLineFormat("{0}={1};", returnValueName, property.InternalFieldName); }
/// <summary> /// Loads the single. /// </summary> /// <param name="returnValueName">Name of the return value.</param> /// <param name="builder">The builder.</param> /// <param name="property">The property.</param> private static void LoadSingle(string returnValueName, StringBuilder builder, IManyToOneProperty property) { builder.AppendLineFormat("if(!{0}&&!(Session0 is null))", property.InternalFieldName + "Loaded") .AppendLine("{") .AppendLineFormat("{0}=Session0.LoadProperty<{1},{2}>(this,\"{3}\");", property.InternalFieldName, property.ParentMapping.ObjectType.GetName(), property.TypeName, property.Name) .AppendLineFormat("{0}=true;", property.InternalFieldName + "Loaded") .AppendLineFormat("if(!({0} is null))", property.InternalFieldName) .AppendLine("{") .AppendLineFormat("({0} as INotifyPropertyChanged).PropertyChanged+=(x,y)=>NotifyPropertyChanged0(\"{1}\");", property.InternalFieldName, property.Name) .AppendLine("}") .AppendLine("}") .AppendLineFormat("{0}={1};", returnValueName, property.InternalFieldName); }