Exemplo n.º 1
0
        protected virtual string GetIdHash(object value, Type type = null)
        {
            type = type ?? value.GetType();
            long id = Meta.GetId(value).Value;

            return(GetIdHash(id, type));
        }
Exemplo n.º 2
0
        private AssignValue GetUniquenessFilter(object instance, Func <string, string> columnNameFormatter)
        {
            Args.ThrowIfNull(instance, nameof(instance));
            object identifier = Meta.GetId(instance);

            if (identifier.Equals(default(long)))
            {
                Args.Throw <InvalidOperationException>("Unable to get unique identifier for specified data: {0}", instance.ToString());
            }
            return(new AssignValue("Id", identifier, columnNameFormatter));
        }
        public void SetParentProperties(object parent, object child)
        {
            Type parentType = parent.GetType();
            Type childType  = child.GetType();
            long parentId   = Meta.GetId(parent).Value;

            foreach (TypeFk typeFk in TypeSchema.ForeignKeys.Where(fk => fk.ForeignKeyType == childType && fk.PrimaryKeyType == parentType))
            {
                typeFk.ForeignKeyProperty.SetValue(child, parentId);
                PropertyInfo parentInstanceProperty = childType.GetProperty(typeFk.PrimaryKeyType.Name);
                if (parentInstanceProperty != null)
                {
                    parentInstanceProperty.SetValue(child, parent);
                }
            }
        }
Exemplo n.º 4
0
 protected internal long?GetIdValue(object value)
 {
     return(Meta.GetId(value));
 }