Пример #1
0
 public void InsertInToDb <T>(ref T item)
     where T : class, new()
 {
     item = SmartDbEntityAgentFactory.Of(item);
     SmartDbBus.PlanToWriteToDb(item, DbActionType.Insert);
     //return item;
 }
Пример #2
0
        public static void Invoke(object @object, string @method, object[] parameter)
        {
            var type = @object.GetType();

            if (!_fields.TryGetValue(type, out var dic))
            {
                dic = new Dictionary <string, DbFieldInfo>();
                IEnumerable <FieldInfo> fields = type.BaseType.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
                foreach (var f in fields)
                {
                    int last = f.Name.IndexOf('>');
                    if (last <= 0)
                    {
                        continue;
                    }
                    string propertyName = f.Name.Substring(1, last - 1);
                    dic.Add($"set_{propertyName}", new DbFieldInfo {
                        FieldInfo = f, PropertyName = propertyName
                    });
                }
                _fields.Add(type, dic);

                var curt = type.BaseType.BaseType;
                while (curt != typeof(object))
                {
                    fields = curt.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
                    foreach (var f in fields)
                    {
                        int last = f.Name.IndexOf('>');
                        if (last <= 0)
                        {
                            continue;
                        }
                        string propertyName = f.Name.Substring(1, last - 1);
                        dic.Add($"set_{propertyName}", new DbFieldInfo {
                            FieldInfo = f, PropertyName = propertyName
                        });
                    }
                    //_fields.Add(type, dic);
                    curt = curt.BaseType;
                }
            }
            var field = dic[@method];

            field.FieldInfo.SetValue(@object, parameter[0]);
            SmartDbBus.PlanToSaveUpdateToDb(@object, field.PropertyName, parameter[0]);
        }
Пример #3
0
 public void DeleteFromDb <T>(T item)
     where T : class, new()
 {
     SmartDbBus.PlanToWriteToDb(item, DbActionType.Delete);
 }
Пример #4
0
 public void Preload(string assemblyName)
 {
     SmartDbBus.PreLoad(assemblyName);
 }
Пример #5
0
 private void WriteToDb(T item, DbActionType type)
 {
     SmartDbBus.PlanToWriteToDb(item, type);
 }