Пример #1
0
        private static void SetupIfIdentity(PropertyInfo property, DommelPropertyMap map)
        {
            if (property.GetCustomAttributes(typeof(DatabaseGeneratedAttribute))
                .FirstOrDefault() is DatabaseGeneratedAttribute dbGenerated)
            {
                // ReSharper disable once ConditionIsAlwaysTrueOrFalse
                // ReSharper disable once UseNullPropagation
                if (dbGenerated == null)
                {
                    return;
                }

                if (dbGenerated.DatabaseGeneratedOption != DatabaseGeneratedOption.Identity)
                {
                    return;
                }

                map.IsIdentity();

                _fastCrudMap
                .SetProperty(property.Name,
                             prop => prop.SetPrimaryKey()
                             .SetDatabaseGenerated(DatabaseGeneratedOption.Identity));
            }
            else
            {
                //assume database generated and pk
                _fastCrudMap
                .SetProperty(property.Name,
                             prop => prop.SetPrimaryKey()
                             .SetDatabaseGenerated(DatabaseGeneratedOption.Identity));
            }
        }