public void WhereClause() { AutoContext db = new AutoContext(); DAIList <Product> products = new DAIList <Product>(); products = db.Product.Where(i => i.Id == 1 && i.ProductName == "Mac" || i.CategoryId != 3).ToList(); }
public void Should_use_value_set_to_JsonProperty_attribute_for_concatentation() { // given var context = new AutoContext <User>(new Uri("http://example.org/ontolgy/User")); // then Assert.Equal("http://example.org/ontolgy/User#with_attribute", context["with_attribute"].ToString()); }
public void When_created_should_include_all_properties() { // given var context = new AutoContext <Issue>(new Uri("http://example.api/o#Issue")); // then Assert.Equal(6, context.Count); }
public void When_created_should_respect_Newtonsoft_property_attribute() { // given var context = new AutoContext <Issue>(new Uri("http://example.api/o#Issue")); // then Assert.NotNull(context["titel"]); }
public void Should_concatenate_with_separator_depending_on_class_id(string issueClassStr, string expectedPropertyId) { // when var context = new AutoContext <Issue>(new Uri(issueClassStr)); // then Assert.Equal(expectedPropertyId, context["projectId"].ToString()); }
public virtual void Delete(T model) { using (var context = new AutoContext()) { context.Entry(model).State = System.Data.Entity.EntityState.Deleted; context.SaveChanges(); } }
public virtual List <T> GetWhere(Expression <Func <T, bool> > expression) { using (var context = new AutoContext()) { var query = context.Set <T>().Where(expression); return(query.ToList()); } }
public virtual void Create(T model) { using (var context = new AutoContext()) { context.Set <T>().Add(model); context.SaveChanges(); } }
public void Should_preserve_existing_context_when_using_declared_class_type() { // given var existing = JObject.Parse("{ 'titel': 'dcterms:title' }"); var context = new AutoContext <Issue>(existing); // then Assert.Equal("dcterms:title", context["titel"].ToString()); }
public void ContextExtensionTest() { ConfigurationManager.ConnectionStrings["DEFAULT"].ToString(); AutoContext db = new AutoContext(); DAIList <Category> cats = db.Category.Where(i => i.Id == 8).ToList(); DbContext a = new DbContext(); a.Adi = "dai"; a.TransformText(); }
public void When_created_should_not_include_reserved_keywords() { // given var context = new AutoContext <Issue>(new Uri("http://example.api/o#Issue")); // then Assert.Null(context[JsonLdKeywords.Id]); Assert.Null(context[JsonLdKeywords.Type]); Assert.Null(context[JsonLdKeywords.Context]); }
public void SaveChanges() { AutoContext db = new AutoContext(); db.Category.AddItem(new Category() { CategoryCode = "cd", CategoryName = "dvd" }); db.SaveChanges(); }
public void When_created_should_not_include_reserved_keywords() { // given var context = new AutoContext <Issue>(new Uri("http://example.api/o#Issue")); // then context.Should().NotContainKey(JsonLdKeywords.Id); context.Should().NotContainKey(JsonLdKeywords.Type); context.Should().NotContainKey(JsonLdKeywords.Context); }
public void When_created_should_extend_given_context_object() { // given var manualContext = JObject.Parse("{ 'titel': 'dcterms:title' }"); // when var context = new AutoContext <Issue>(manualContext, new Uri("http://example.api/o#Issue")); // then Assert.Equal("dcterms:title", context["titel"].ToString()); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); var autoContext = new AutoContext(); Database.SetInitializer(new AutoInitializer()); autoContext.Database.Initialize(true); }
public void Update() { OrmEngine.Instance().InitializeDatabase(); AutoContext db = new AutoContext(); DAIList <Category> categories = db.Category.ToList(); Category category = categories[0]; category.CategoryName = "pc3"; db.Category.Update(category); //provider.Update(new Product() { Id = 2, ProductCode = "Ali", ProductName= "Kaya" }); db.SaveChanges(); }
public void When_modified_should_allow_changing_property_definition() { // given var context = new AutoContext <Issue>(new Uri("http://example.api/o#Issue")); var expectedMapping = JObject.Parse(@"{ '@id': 'http://example.api/o#Issue/projectId', '@type': '@id' }"); // when context.Property(i => i.ProjectId, propName => propName.Type().Id()); // then Assert.True(JToken.DeepEquals(context["projectId"], expectedMapping)); }
public virtual List <T> GetWhereWithIncludes(Expression <Func <T, bool> > expression, params Expression <Func <T, object> >[] includes) { using (var context = new AutoContext()) { IQueryable <T> dataset = context.Set <T>(); if (includes.Any()) { foreach (var item in includes) { dataset = dataset.Include(item); } } if (expression != null) { dataset = dataset.Where(expression); } return(dataset.ToList()); } }
public void CodeGeneration() { List <Category> dai = new List <Category>(); //Category a = new Category(); //a.CategoryCode = "dai"; //DbContext context = new DbContext(); //OrmEngine.Instance().InitializeDatabase(); //Product b = new Product(); //b.ProductCode = "a"; //context.Product.Add(b); //DAIList<Product> cat = context.Product.Where(p => p.ProductCode == "a"); AutoContext db = new AutoContext(); DAIList <Category> cat = db.Category.Where(p => p.CategoryName == "mac"); DAIList <Product> Products = db.Product.ToList().OrderByDescending(p => p.Id); Product a = Products[0]; var b = a.Categories; }
public void When_modified_should_allow_remapping_expanded_property_definition() { // given var contextBefore = JObject.Parse(@"{ 'projectId': { '@id': 'http://example.api/o#Issue/projectId', '@type': '@vocab' } }"); var context = new AutoContext <Issue>(contextBefore, new Uri("http://example.api/o#Issue")); var contextAfter = JObject.Parse(@" { '@id': 'http://example.api/o#Issue/projectId', '@type': '@id' }"); // when context.Property(i => i.ProjectId, propName => propName.Type().Id()); // then Assert.True(JToken.DeepEquals(context["projectId"], contextAfter)); }
public TriggerT(AutoContext context) { _context = context; }
public TriggersController(AutoContext context) { _context = context; }
public IHttpActionResult PostDeleteAll() { var context = new AutoContext(); var contextAuto = context.Cars; foreach (var item in contextAuto) { contextAuto.Remove(item); } context.SaveChanges(); return Ok("All cars deleted"); }
public void SkipTake() { DAIList <Category> cats = new AutoContext().Category.ToList().Skip(1).Take(2); }
public void RelationMap() { AutoContext db = new AutoContext(); DAIList <Product> products = db.Product.ToList(); DAIList <Category> cat = products[0].Categories; }
public AspNetUsersController(AutoContext context) { db = context; }
public ActionsController(AutoContext context) { _context = context; }
public CarRepository(AutoContext context) { this.db = context; }
public ProfilController(AutoContext _db) { db = _db; }
public BrandRepository(AutoContext db) { this.db = db; }
public KomentarController(AutoContext context) { db = context; }