private void IfSetNull(string sourceEntity, ReferencedObject refObj, object refValue, Dictionary <string, DeleteInfo> setNullEntitys, Action <string, object, object> action) { if (refObj.DeleteFlag == DeleteFlag.SetNull) { string name = refObj.EntityType.Name; IEntitySchema schema = IEntitySchemaHelper.Get(name); IList list = this.FindReferenceds(name, refObj, refValue); foreach (object obj2 in list) { object keyValue = schema.GetKeyValue(obj2); DeleteInfo info = new DeleteInfo { Id = keyValue, EntitySchema = schema, RefObject = refObj }; Console.WriteLine(string.Format("找到置为空的数据:{0}", info.Key)); if (setNullEntitys.ContainsKey(info.Key)) { Console.WriteLine("已存在,不添加"); } else { setNullEntitys.Add(info.Key, info); Console.WriteLine("添加"); } } } }
private void IfCascadeDelete(string sourceEntity, ReferencedObject refObj, object refValue, Dictionary <string, DeleteInfo> deleteEntitys, Action <string, object, object> action) { if (refObj.DeleteFlag == DeleteFlag.CascadeDelete) { string name = refObj.EntityType.Name; IEntitySchema schema = IEntitySchemaHelper.Get(name); IList list = this.FindReferenceds(name, refObj, refValue); foreach (object obj2 in list) { object keyValue = schema.GetKeyValue(obj2); DeleteInfo info = new DeleteInfo { Id = keyValue, EntitySchema = schema, RefObject = refObj }; Console.WriteLine(string.Format("找到需要删除的数据:{0}", info.Key)); if (deleteEntitys["current_delete_entity"].Equals(info)) { Console.WriteLine("父对象,不添加"); } else if (deleteEntitys.ContainsKey(info.Key)) { Console.WriteLine("已存在,不添加"); } else { deleteEntitys.Add(info.Key, info); Console.WriteLine("添加"); action(name, obj2, keyValue); } } } }
private IList FindReferenceds(string sourceEntity, ReferencedObject refObj, object refValue) { string str = this._context.AddPrefixToParameterName("refFieldValue"); DbParameter parameter = this._context.CreateParameter(); parameter.ParameterName = str; parameter.Value = refValue; string condition = string.Format("{0} = {1}", refObj.ReferenceField, str); return(this._context.Where(refObj.EntityType, condition, new DbParameter[] { parameter })); }
public override string ToString() { if (ReferencedObject != null) { return(ReferencedObject.ToString()); } else { return(base.ToString()); } }
public override void Write(ICSharpFormatter formatter, bool comment = true) { if (ReferencedObject != null) { ReferencedObject.Write(formatter, comment); } else { base.Write(formatter, comment); } }
private void IfNotAllowed(string sourceEntity, ReferencedObject refObj, object refFieldValue) { if (refObj.DeleteFlag == DeleteFlag.NotAllowed) { string str = this._context.AddPrefixToParameterName("refFieldValue"); DbParameter parameter = this._context.CreateParameter(); parameter.ParameterName = str; parameter.Value = refFieldValue; if (this._context.ExecuteDataTable(string.Format(" {0} = {1}", refObj.ReferenceField, str), new DbParameter[] { parameter }).Rows.Count != 0) { throw new DeleteException(string.Format("对象 {0},Id : {1} 的被引用项 {2} 不允许级联操作", sourceEntity, refFieldValue, refObj.EntityType.Name)); } } }
public override void UpdateDatabaseAfterUpdateSchema() { base.UpdateDatabaseAfterUpdateSchema(); if (ObjectSpace.GetObjectsCount(typeof(ExampleObject), null) == 0) { for (int i = 0; i < 5; i++) { ReferencedObject refObject = ObjectSpace.CreateObject <ReferencedObject>(); refObject.Name = string.Format("Owner Object {0:d}", i + 1); ExampleObject exampleObj = ObjectSpace.CreateObject <ExampleObject>(); exampleObj.Name = string.Format("Example object {0:d}", i + 1); exampleObj.LookupReferencedObject = refObject; } ObjectSpace.CommitChanges(); } }
public void CheckForErrorsAndClear() { if (Prefs.DevMode) { if (!Scribe.saver.savingForDebug) { foreach (ReferencedObject item in this.referenced) { ReferencedObject current = item; if (!this.deepSaved.Contains(current.loadID)) { Log.Warning("Object with load ID " + current.loadID + " is referenced (xml node name: " + current.label + ") but is not deep-saved. This will cause errors during loading."); } } } this.Clear(); } }
public static void SetValue(DependencyObject target, ReferencedObject<string> value) { target.SetValue(ValueProperty, value); }
public bool HideReferencedObject(ReferencedObject referencedObject) { return !visible; }
public ChildProxy() { _referencedObject = new ReferencedObject(); _serializableObject = new SerializableObject(); _nonSerializableObject = new NonSerializableObject(); }
public string AvailableReferencedObject(ReferencedObject referencedObject) { return available ? null : "not available"; }
public static ReferencedObject CreateReferencedObject(string objectReference) { ReferencedObject referencedObject = new ReferencedObject(); referencedObject.ObjectReference = objectReference; return referencedObject; }
public static void SetValue(DependencyObject target, ReferencedObject <string> value) { target.SetValue(ValueProperty, value); }
public void AddToReferencedObjects(ReferencedObject referencedObject) { base.AddObject("ReferencedObjects", referencedObject); }
public string ValidReferencedObject(ReferencedObject referencedObject) { return valid ? null : "not valid"; }