示例#1
0
        public static DBFields GetDbFields <TEntityType>(this TEntityType entity) where TEntityType : IDbEntity
        {
            if (entity == null)
            {
                return(null);
            }
            var map = DbMapping.Get(entity.GetType());

            if (map?.PropertiesInfos == null || map.PropertiesInfos.Count == 0)
            {
                return(null);
            }
            var fields = new DBFields();

            foreach (var property in map.PropertiesInfos)
            {
                var value = property.GetValue(entity);
                if (value == null)
                {
                    continue;
                }
                fields.SetEx(property.Name, value);
            }
            return(fields);
        }
示例#2
0
        public static DbRecord ToDbRecord(this DBRecord record)
        {
            if (record == null)
            {
                return(null);
            }
            var map = DbMapping.Get(record.Table.TableId);

            return(new DbRecord(record));
        }
示例#3
0
        public void Sync()
        {
            var changes = DropboxDatastore?.Sync();

            if (changes != null && changes.Count > 0)
            {
                foreach (var change in changes)
                {
                    var map = DbMapping.Get(change.Key);
                    if (map == null)
                    {
                        continue;
                    }
                    foreach (var record in change.Value)
                    {
                        DbRecordChanged?.Invoke(this, new DbRecordChangedEventArgs(record.ToDbRecord()));
                    }
                }
            }
        }