public static void Ctor_DatabaseGeneratedOption(DatabaseGeneratedOption databaseGeneratedOption)
 {
     DatabaseGeneratedAttribute attribute = new DatabaseGeneratedAttribute(databaseGeneratedOption);
     Assert.Equal(databaseGeneratedOption, attribute.DatabaseGeneratedOption);
 }
Esempio n. 2
0
        public override InternalPropertyBuilder Apply(InternalPropertyBuilder propertyBuilder, DatabaseGeneratedAttribute attribute, MemberInfo clrMember)
        {
            FirebirdValueGenerationStrategy?valueGenerationStrategy = null;
            ValueGenerated valueGenerated = ValueGenerated.Never;

            if (attribute.DatabaseGeneratedOption == DatabaseGeneratedOption.Computed)
            {
                valueGenerated          = ValueGenerated.OnAddOrUpdate;
                valueGenerationStrategy = FirebirdValueGenerationStrategy.ComputedColumn;
            }
            else if (attribute.DatabaseGeneratedOption == DatabaseGeneratedOption.Identity)
            {
                valueGenerated          = ValueGenerated.OnAdd;
                valueGenerationStrategy = FirebirdValueGenerationStrategy.IdentityColumn;
            }

            propertyBuilder.ValueGenerated(valueGenerated, ConfigurationSource.Convention);
            propertyBuilder.Firebird(ConfigurationSource.DataAnnotation).ValueGenerationStrategy(valueGenerationStrategy);

            return(base.Apply(propertyBuilder, attribute, clrMember));
        }
        public virtual bool IsDatabaseGenerated(PropertyInfo propertyInfo)
        {
            DatabaseGeneratedAttribute attribute = propertyInfo.GetCustomAttribute <DatabaseGeneratedAttribute>();

            return(attribute != null && attribute.DatabaseGeneratedOption != DatabaseGeneratedOption.None);
        }
Esempio n. 4
0
 private static object[] GetArgs(DatabaseGeneratedAttribute attribute)
 {
     return(new object[] { attribute.DatabaseGeneratedOption });
 }
Esempio n. 5
0
 public AppVentaCursosContext()
 {
     DatabaseGeneratedAttribute.SetCommandTimeout(150000);
 }
Esempio n. 6
0
        public static List <DbDescription> GetDescription()
        {
            var d = new List <DbDescription>();

            var e = Assembly.Load(b);
            var f = e?.GetTypes();
            var g = f?
                    .Where(t => t.IsClass &&
                           !t.IsGenericType &&
                           !t.IsAbstract
                           //&& t.GetInterfaces().Any(m => m.GetGenericTypeDefinition() == typeof(IBaseModel<>))
                           ).ToList();

            foreach (var h in g)
            {
                var i = new DbDescription();

                System.Type          t           = e.GetType(h.FullName);
                DescriptionAttribute attributeTB = Attribute.GetCustomAttribute(t, typeof(DescriptionAttribute)) as DescriptionAttribute;
                var z = "";
                if (attributeTB != null)
                {
                    z = attributeTB.Description;
                }
                var n = new List <DbDescription>();

                //3.2.3 获取实体类所有的公共属性
                List <PropertyInfo> propertyInfos = t.GetProperties(BindingFlags.Instance | BindingFlags.Public).ToList();
                propertyInfos.ForEach(p =>
                {
                    //Console.WriteLine(p.Name);
                    DescriptionAttribute attribute = Attribute.GetCustomAttribute(p, typeof(DescriptionAttribute)) as DescriptionAttribute;

                    DatabaseGeneratedAttribute dbattribute = Attribute.GetCustomAttribute(p, typeof(DatabaseGeneratedAttribute)) as DatabaseGeneratedAttribute;


                    if (attribute != null || (dbattribute != null && dbattribute.DatabaseGeneratedOption == DatabaseGeneratedOption.Identity))
                    {
                        var dect   = attribute != null ? attribute.Description : "";
                        int iszzpk = 0;
                        if (dbattribute != null && dbattribute.DatabaseGeneratedOption == DatabaseGeneratedOption.Identity)
                        {
                            iszzpk = 1;
                        }
                        n.Add(new DbDescription {
                            Name = p.Name, Description = dect, IsZZPK = iszzpk
                        });
                    }



                    #region MyRegion
                    //var j = c + "\\" + h.Name + ".cs";
                    //var k = File.ReadAllText(j);
                    //k = k.Substring(k.IndexOf("{") + 1, k.LastIndexOf("}") - k.IndexOf("{") - 1).Replace("\n", "");

                    //var l = k.Substring(k.IndexOf(" {") + 2, k.LastIndexOf(" }") - k.IndexOf(" {") - 1).Replace("\n", "");
                    //string[] slipt = { "}\r" };
                    //var m = l.Split(slipt, StringSplitOptions.None).ToList();

                    //var n = new List<DbDescription>();
                    //foreach (var o in m)
                    //{
                    //    var p = o.Replace("///", "");

                    //    var q = p.IndexOf("<summary>");
                    //    var r = p.LastIndexOf("</summary>");

                    //    var s = p.IndexOf("public");
                    //    var t = p.IndexOf("{");

                    //    var u = (q > 0 && r > 0) ? p.Substring(q + 9, r - q - 10).Replace("\r", "").Replace(" ", "") : "";
                    //    var v = (s > 0 && t > 0) ? p.Substring(s, t - s).Split(' ')[2] : "";

                    //    n.Add(new DbDescription()
                    //    {
                    //        Description = u,
                    //        Name = v
                    //    });
                    //}

                    //var w = k.Substring(0, k.IndexOf("{\r") - 1);
                    //w = w.Replace("///", "");

                    //var x = w.IndexOf("<summary>");
                    //var y = w.LastIndexOf("</summary>");
                    //var z = (x > 0 && y > 0) ? w.Substring(x + 9, y - x - 10).Replace("\r", "").Replace(" ", "") : "";
                    #endregion
                });

                d.Add(new DbDescription()
                {
                    Name        = h.Name,
                    Description = z,
                    Column      = n
                });
            }
            return(d);
        }
Esempio n. 7
0
        public static void Ctor_DatabaseGeneratedOption(DatabaseGeneratedOption databaseGeneratedOption)
        {
            DatabaseGeneratedAttribute attribute = new DatabaseGeneratedAttribute(databaseGeneratedOption);

            Assert.Equal(databaseGeneratedOption, attribute.DatabaseGeneratedOption);
        }