protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder) { Database.SetInitializer<ProjetoModeloContext>(null); //Database.SetInitializer<ProjetoModeloContext>(new CreateDatabaseIfNotExists<ProjetoModeloContext>()); modelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>(); modelBuilder.Conventions.Remove<ManyToManyCascadeDeleteConvention>(); //modelBuilder.Properties().Where(p=>p.Name==p.ReflectedType+"Id").Configure(p=>p.IsKey()); modelBuilder.Properties() .Where(p => p.Name == p.ReflectedType.Name + "Id") .Configure(p => p.IsKey()); modelBuilder.Properties<string>() .Configure(p => p.HasColumnType("varchar")); modelBuilder.Properties<string>() .Configure(p => p.HasMaxLength(100)); modelBuilder.Configurations.Add(new ClienteConfiguration()); modelBuilder.Configurations.Add(new ProdutoConfiguration()); }
public void CovariantIJEnumerable() { IEnumerable<JObject> o = new[] { JObject.FromObject(new {First = 1, Second = 2}), JObject.FromObject(new {First = 1, Second = 2}) }; IJEnumerable<JToken> values = o.Properties(); Assert.AreEqual(4, values.Count()); }
public void PropertiesWorksWithArray() { Person[] persons = new[] { new Person { Name = "Thomas", Age = 38 }, new Person { Name = "Achille", Age = 10, Nationality = Nationality.French }, new Person { Name = "Anton", Age = 7, Nationality = Nationality.French }, new Person { Name = "Arjun", Age = 7, Nationality = Nationality.Indian } }; Check.That(persons.Properties("Name")).ContainsExactly("Thomas", "Achille", "Anton", "Arjun"); Check.That(persons.Properties("Age")).ContainsExactly(38, 10, 7, 7); Check.That(persons.Properties("Nationality")).ContainsExactly(Nationality.Unknown, Nationality.French, Nationality.French, Nationality.Indian); }
public void ObjectProperties_NestedArrayPropertyReturned_ReturnsSplitSequences() { var input = new[] { ModelGrammar.TokenObjectBeginUnnamed, ModelGrammar.TokenProperty("key1"), ModelGrammar.TokenNull, ModelGrammar.TokenProperty("key2"), ModelGrammar.TokenArrayBeginUnnamed, ModelGrammar.TokenFalse, ModelGrammar.TokenPrimitive(42), ModelGrammar.TokenArrayEnd, ModelGrammar.TokenProperty("three"), ModelGrammar.TokenPrimitive("Hello!"), ModelGrammar.TokenProperty("4"), ModelGrammar.TokenTrue, ModelGrammar.TokenObjectEnd }; var expected = new Dictionary<DataName, IEnumerable<Token<ModelTokenType>>> { { new DataName("key2"), new[] { ModelGrammar.TokenArrayBeginUnnamed, ModelGrammar.TokenFalse, ModelGrammar.TokenPrimitive(42), ModelGrammar.TokenArrayEnd, } } }; // select all properties var actual = input.Properties(name => name.LocalName == "key2").ToArray(); Assert.Equal(expected, actual, false); }