public void Customize(BusConfiguration configuration) { XmlConfigurator.Configure(); configuration.UseContainer<NinjectBuilder>(k => k.ExistingKernel(CreateKernel())); configuration.RegisterComponents(x => x.ConfigureComponent<IRepository>( builder => { return new Repository(() => { var nh = builder.Build<NHibernateStorageContext>(); var e = new OrderContext((DbConnection)nh.Connection); return e; }); }, DependencyLifecycle.InstancePerUnitOfWork)); configuration.RegisterComponents(components => components.ConfigureComponent<UnitOfWork>(DependencyLifecycle.InstancePerUnitOfWork)); configuration.UsePersistence<NHibernatePersistence>(); configuration.UseTransport<MsmqTransport>(); configuration.UseDataBus<FileShareDataBus>().BasePath(Constants.NServiceBus_DataBusBasePath); configuration.RijndaelEncryptionService(); configuration.Transactions(); configuration.EnableOutbox(); configuration.Conventions().OrderConventions(); // }
private static void CreateProduct() { var product = new Product { Name = "Camry", Description = "Toyota Camry Sedan", Producer = "Toyota", Price = 20000.00 }; var ctx = new OrderContext(); ctx.Products.Add(product); ctx.SaveChanges(); }
public OrderListViewModel( OrderContext orderService, IEventAggregator eventAggregator ) { // Event aggregator for publishing loosely coupled events. _eventAggregator = eventAggregator; // Order service context for loading Order data from web service. _orderService = orderService; // Wrap the order entity list in a PagedCollectionView. _orderCollectionView = new PagedCollectionView( _orderService.Orders ); // Track the currently selected item. _orderCollectionView.CurrentChanged += SelectedOrderChanged; // Start loading the orders collection using the order service. LoadOperation load = _orderService.Load( _orderService.GetOrdersQuery(), OnOrdersLoaded, null ); }
// // GET: /Home/ public ActionResult Index() { var ctx = new OrderContext(); //var orders = (from o in ctx.Orders // select new OrderModel() o.ProductOrders).ToList(); //var orders = ctx.Orders.Include("ProductOrders").ToList(); //var orders = ctx.Orders.Include("ProductOrders").Include("ProductOrders.Product").ToList(); var orders = ctx.Orders.Include(o => o.ProductOrders) .Include(o => o.ProductOrders.Select(p => p.Product)) .Where(o => o.Id == 1) .ToList(); //var orders = ctx.Orders.ToList(); //foreach (var order in orders) //{ // ctx.Entry(order).Collection(x => x.ProductOrders).Load(); //} var model = new OrderModel { Orders = orders }; return View(model); }
public void Shipment(OrderContext order) { throw new System.NotImplementedException(); }
public OrderItemsController(OrderContext context) { _context = context; }
public RepositoryBase(OrderContext dbContext) { _dbContext = dbContext; }
/// <inheritdoc /> public Task CreateOrder(Order order, OrderContext context) { throw new Exception("Тунцни лососца"); }
public GenericService(OrderContext context) : base(context) { }
public ProductService(OrderContext context) : base(context) { }
public Task <Result <string> > Run(OrderContext context) { //Roll back any changes return(Task.FromResult(Result.Ok("Order Aborted"))); }
//public CustomerService(OrderContext dbContext, IMessageQ messageQ) //{ // _dbConext = dbContext; // _messageQ = messageQ; //} public CustomerService(OrderContext dbContext, IBus bus) { _dbConext = dbContext; _bus = bus; }
public void Test1() { var tuser = g.sqlite.Select <TestUser>().Where(u => u.accname == "admin") .InnerJoin(a => a.LogOn.id == a.stringid).ToSql(); using (var ctx = new OrderContext()) { //ctx.Orders.OrmInsert(new Order { }).ExecuteAffrows(); //ctx.Orders.OrmDelete.Where(a => a.Id > 0).ExecuteAffrows(); //ctx.OrderDetails.OrmSelect.Where(dt => dt.Order.Id == 10).ToList(); ctx.SaveChanges(); } var parentSelect1 = select.Where(a => a.Type.Parent.Parent.Parent.Parent.Name == "").Where(b => b.Type.Name == "").ToSql(); var collSelect1 = g.mysql.Select <Order>().Where(a => a.OrderDetails.AsSelect().Any(b => b.Id > 100) ); var collectionSelect = select.Where(a => //a.Type.Guid == a.TypeGuid && //a.Type.Parent.Id == a.Type.ParentId && a.Type.Parent.Types.AsSelect().Where(b => b.Name == a.Title).Any( //b => b.ParentId == a.Type.Parent.Id ) ); var collectionSelect2 = select.Where(a => a.Type.Parent.Types.AsSelect().Where(b => b.Name == a.Title).Any( b => b.Parent.Name == "xxx" && b.Parent.Parent.Name == "ccc" && b.Parent.Parent.Parent.Types.AsSelect().Any(cb => cb.Name == "yyy") ) ); var collectionSelect3 = select.Where(a => a.Type.Parent.Types.AsSelect().Where(b => b.Name == a.Title).Any( bbb => bbb.Parent.Types.AsSelect().Where(lv2 => lv2.Name == bbb.Name + "111").Any( ) ) ); var order = g.mysql.Select <Order>().Where(a => a.Id == 1).ToOne(); //查询订单表 if (order == null) { var orderId = g.mysql.Insert(new Order { }).ExecuteIdentity(); order = g.mysql.Select <Order>(orderId).ToOne(); } var orderDetail1 = order.OrderDetails; //第一次访问,查询数据库 var orderDetail2 = order.OrderDetails; //第二次访问,不查 var order1 = orderDetail1.FirstOrDefault(); //访问导航属性,此时不查数据库,因为 OrderDetails 查询出来的时候已填充了该属性 var queryable = g.mysql.Queryable <TestInfo>().Where(a => a.Id == 1).ToList(); var sql2222 = select.Where(a => select.Where(b => b.Id == a.Id && select.Where(c => c.Id == b.Id).Where(d => d.Id == a.Id).Where(e => e.Id == b.Id) .Offset(a.Id) .Any() ).Any() ).ToList(); var groupby = g.mysql.Select <TestInfo>().From <TestTypeInfo, TestTypeParentInfo>((s, b, c) => s .Where(a => a.Id == 1) ) .GroupBy((a, b, c) => new { tt2 = a.Title.Substring(0, 2), mod4 = a.Id % 4 }) .Having(a => a.Count() > 0 && a.Avg(a.Key.mod4) > 0 && a.Max(a.Key.mod4) > 0) .Having(a => a.Count() < 300 || a.Avg(a.Key.mod4) < 100) .OrderBy(a => a.Key.tt2) .OrderByDescending(a => a.Count()) .ToList(a => new { a.Key.tt2, cou1 = a.Count(), arg1 = a.Avg(a.Key.mod4), ccc2 = a.Key.tt2 ?? "now()", //ccc = Convert.ToDateTime("now()"), partby = Convert.ToDecimal("sum(num) over(PARTITION BY server_id,os,rid,chn order by id desc)") }); var arrg = g.mysql.Select <TestInfo>().ToAggregate(a => new { sum = a.Sum(a.Key.Id + 11.11), avg = a.Avg(a.Key.Id), count = a.Count(), max = a.Max(a.Key.Id), min = a.Min(a.Key.Id) }); var arrg222 = g.mysql.Select <NullAggreTestTable>().ToAggregate(a => new { sum = a.Sum(a.Key.Id + 11.11), avg = a.Avg(a.Key.Id), count = a.Count(), max = a.Max(a.Key.Id), min = a.Min(a.Key.Id) }); var t1 = g.mysql.Select <TestInfo>().Where("").Where(a => a.Id > 0).Skip(100).Limit(200).ToList(); var t2 = g.mysql.Select <TestInfo>().As("b").Where("").Where(a => a.Id > 0).Skip(100).Limit(200).ToList(); var sql1 = select.LeftJoin(a => a.Type.Guid == a.TypeGuid).ToList(); var sql2 = select.LeftJoin <TestTypeInfo>((a, b) => a.TypeGuid == b.Guid && b.Name == "111").ToList(); var sql3 = select.LeftJoin("TestTypeInfo b on b.Guid = a.TypeGuid").ToList(); //g.mysql.Select<TestInfo, TestTypeInfo, TestTypeParentInfo>().Join((a, b, c) => new Model.JoinResult3( // Model.JoinType.LeftJoin, a.TypeGuid == b.Guid, // Model.JoinType.InnerJoin, c.Id == b.ParentId && c.Name == "xxx") //); //var sql4 = select.From<TestTypeInfo, TestTypeParentInfo>((a, b, c) => new SelectFrom() // .InnerJoin(a.TypeGuid == b.Guid) // .LeftJoin(c.Id == b.ParentId) // .Where(b.Name == "xxx")) //.Where(a => a.Id == 1).ToSql(); var sql4 = select.From <TestTypeInfo, TestTypeParentInfo>((s, b, c) => s .InnerJoin(a => a.TypeGuid == b.Guid) .LeftJoin(a => c.Id == b.ParentId) .Where(a => b.Name == "xxx")).ToList(); //.Where(a => a.Id == 1).ToSql(); var list111 = select.From <TestTypeInfo, TestTypeParentInfo>((s, b, c) => s .InnerJoin(a => a.TypeGuid == b.Guid) .LeftJoin(a => c.Id == b.ParentId) .Where(a => b.Name != "xxx")).ToList((a, b, c) => new { a.Id, a.Title, a.Type, ccc = new { a.Id, a.Title }, tp = a.Type, tp2 = new { a.Id, tp2 = a.Type.Name }, tp3 = new { a.Id, tp33 = new { a.Id } } }); var ttt122 = g.mysql.Select <TestTypeParentInfo>().Where(a => a.Id > 0).ToList(); var sql5 = g.mysql.Select <TestInfo>().From <TestTypeInfo, TestTypeParentInfo>((s, b, c) => s).Where((a, b, c) => a.Id == b.ParentId).ToList(); //((JoinType.LeftJoin, a.TypeGuid == b.Guid), (JoinType.InnerJoin, b.ParentId == c.Id) var t11112 = g.mysql.Select <TestInfo>().ToList(a => new { a.Id, a.Title, a.Type, ccc = new { a.Id, a.Title }, tp = a.Type, tp2 = new { a.Id, tp2 = a.Type.Name }, tp3 = new { a.Id, tp33 = new { a.Id } } }); var t100 = g.mysql.Select <TestInfo>().Where("").Where(a => a.Id > 0).Skip(100).Limit(200).Caching(50).ToList(); var t101 = g.mysql.Select <TestInfo>().As("b").Where("").Where(a => a.Id > 0).Skip(100).Limit(200).Caching(50).ToList(); var t1111 = g.mysql.Select <TestInfo>().ToList(a => new { a.Id, a.Title, a.Type }); var t2222 = g.mysql.Select <TestInfo>().ToList(a => new { a.Id, a.Title, a.Type.Name }); var t3 = g.mysql.Insert <TestInfo>(new[] { new TestInfo { }, new TestInfo { } }).IgnoreColumns(a => a.Title).ToSql(); var t4 = g.mysql.Insert <TestInfo>(new[] { new TestInfo { }, new TestInfo { } }).IgnoreColumns(a => new { a.Title, a.CreateTime }).ToSql(); var t5 = g.mysql.Insert <TestInfo>(new[] { new TestInfo { }, new TestInfo { } }).IgnoreColumns(a => new { a.Title, a.TypeGuid, a.CreateTime }).ToSql(); var t6 = g.mysql.Insert <TestInfo>(new[] { new TestInfo { }, new TestInfo { } }).InsertColumns(a => new { a.Title }).ToSql(); var t7 = g.mysql.Update <TestInfo>().ToSql(); var t8 = g.mysql.Update <TestInfo>().Where(new TestInfo { }).ToSql(); var t9 = g.mysql.Update <TestInfo>().Where(new[] { new TestInfo { Id = 1 }, new TestInfo { Id = 2 } }).ToSql(); var t10 = g.mysql.Update <TestInfo>().Where(new[] { new TestInfo { Id = 1 }, new TestInfo { Id = 2 } }).Where(a => a.Title == "111").ToSql(); var t11 = g.mysql.Update <TestInfo>().SetSource(new[] { new TestInfo { Id = 1, Title = "111" }, new TestInfo { Id = 2, Title = "222" } }).ToSql(); var t12 = g.mysql.Update <TestInfo>().SetSource(new[] { new TestInfo { Id = 1, Title = "111" }, new TestInfo { Id = 2, Title = "222" } }).Where(a => a.Title == "111").ToSql(); var t13 = g.mysql.Update <TestInfo>().Set(a => a.Title, "222111").ToSql(); var t14 = g.mysql.Update <TestInfo>().Set(a => a.Title, "222111").Where(new TestInfo { }).ToSql(); var t15 = g.mysql.Update <TestInfo>().Set(a => a.Title, "222111").Where(new[] { new TestInfo { Id = 1 }, new TestInfo { Id = 2 } }).ToSql(); var t16 = g.mysql.Update <TestInfo>().Set(a => a.Title, "222111").Where(new[] { new TestInfo { Id = 1 }, new TestInfo { Id = 2 } }).Where(a => a.Title == "111").ToSql(); var t17 = g.mysql.Update <TestInfo>().SetSource(new[] { new TestInfo { Id = 1, Title = "111" }, new TestInfo { Id = 2, Title = "222" } }).Set(a => a.Title, "222111").ToSql(); var t18 = g.mysql.Update <TestInfo>().SetSource(new[] { new TestInfo { Id = 1, Title = "111" }, new TestInfo { Id = 2, Title = "222" } }).Set(a => a.Title, "222111").Where(a => a.Title == "111").ToSql(); var t19 = g.mysql.Update <TestInfo>().Set(a => a.TypeGuid + 222111).ToSql(); var t20 = g.mysql.Update <TestInfo>().Set(a => a.TypeGuid + 222111).Where(new TestInfo { }).ToSql(); var t21 = g.mysql.Update <TestInfo>().Set(a => a.TypeGuid + 222111).Where(new[] { new TestInfo { Id = 1 }, new TestInfo { Id = 2 } }).ToSql(); var t22 = g.mysql.Update <TestInfo>().Set(a => a.TypeGuid + 222111).Where(new[] { new TestInfo { Id = 1 }, new TestInfo { Id = 2 } }).Where(a => a.Title == "111").ToSql(); var t23 = g.mysql.Update <TestInfo>().SetSource(new[] { new TestInfo { Id = 1, Title = "111" }, new TestInfo { Id = 2, Title = "222" } }).Set(a => a.TypeGuid + 222111).ToSql(); var t24 = g.mysql.Update <TestInfo>().SetSource(new[] { new TestInfo { Id = 1, Title = "111" }, new TestInfo { Id = 2, Title = "222" } }).Set(a => a.TypeGuid + 222111).Where(a => a.Title == "111").ToSql(); }
public OrderProductsController(OrderContext context) { _context = context; }
public DishRepository(OrderContext context) : base(context) { }
public Repository(OrderContext orderContext) { this.orderContext = orderContext; }
public Repository(OrderContext orderContext) { _orderContext = orderContext; }
//构造函数把TodoContext 作为参数, //Asp.net core 框架可以自动注入TodoContext对象 public OrderController(OrderContext context) { this.OrderWebdb = context; }
public SalesOrderService(OrderContext context) : base(context) { }
public RepositoryBase(OrderContext dbContext) { _dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext)); }
public OrderService(OrderContext context, MoMoPaymentHelper moMoPaymentHelper, IMapper mapper) { _context = context; _moMoPaymentHelper = moMoPaymentHelper; _mapper = mapper; }
private static async Task <Object[]> Execute <T>(String request, Object requestData, Func <OrderContext, IEnumerable <T> > fromDbFunc) { var fixture = new NC_RDBNull_DbFixtureInitDb(); await fixture.Initalize(); var parser = new OeParser(new Uri("http://dummy/"), fixture.EdmModel); var responseStream = new MemoryStream(); var requestUri = new Uri(@"http://dummy/" + request); if (requestData == null) { await parser.ExecuteGetAsync(requestUri, OeRequestHeaders.JsonDefault, responseStream, CancellationToken.None); } else { String data = JsonConvert.SerializeObject(requestData); var requestStream = new MemoryStream(Encoding.UTF8.GetBytes(data)); await parser.ExecutePostAsync(requestUri, OeRequestHeaders.JsonDefault, requestStream, responseStream, CancellationToken.None); } ODataPath path = OeParser.ParsePath(fixture.EdmModel, new Uri("http://dummy/"), requestUri); var reader = new ResponseReader(fixture.EdmModel.GetEdmModel(path)); responseStream.Position = 0; Object[] fromOe; if (typeof(T) == typeof(int)) { String count = new StreamReader(responseStream).ReadToEnd(); fromOe = count == "" ? null : new Object[] { int.Parse(count) }; } else if (typeof(T) == typeof(String)) { String json = new StreamReader(responseStream).ReadToEnd(); var jobject = (Newtonsoft.Json.Linq.JObject)JsonConvert.DeserializeObject(json); var jarray = (Newtonsoft.Json.Linq.JArray)jobject["value"]; fromOe = jarray.Select(j => (String)j).ToArray(); } else { fromOe = reader.Read(responseStream).Cast <Object>().ToArray(); } if (fromDbFunc == null) { return(fromOe); } T[] fromDb; using (OrderContext orderContext = fixture.CreateContext()) fromDb = fromDbFunc(orderContext).ToArray(); var settings = new JsonSerializerSettings() { DateFormatString = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffff", DateTimeZoneHandling = DateTimeZoneHandling.Utc, ReferenceLoopHandling = ReferenceLoopHandling.Ignore, NullValueHandling = NullValueHandling.Ignore }; String jsonOe = JsonConvert.SerializeObject(fromOe, settings); String jsonDb = JsonConvert.SerializeObject(fromDb, settings); Console.WriteLine(requestUri); Assert.Equal(jsonDb, jsonOe); return(fromOe); }
public RestaurantsController(OrderContext context) { _context = context; }
public OrderRepository(OrderContext dbContext) : base(dbContext) { }
public OrderRepository(OrderContext orderContext) { _orderContext = orderContext; _dbSet = _orderContext.Set <T>(); }
public OrderDetailsController(OrderContext context) { _context = context; }
public OrderRepository(OrderContext db) { _db = db; }
public OrderItemController(OrderContext context) { this.orderDB = context; IQueryable <Order> query = orderDB.Orders; }
public AddressService(OrderContext context) : base(context) { }
public MovieController(OrderContext context) { _context = context; }
void SetupDevelopmentDatabase() { Database.SetInitializer(new DropCreateDatabaseIfModelChanges<OrderContext>()); using (var context = new OrderContext("NServiceBus/Persistence")) context.Database.Initialize(true); }
public OrderController(OrderContext orderContext) { _orderContext = orderContext; }
public OrderController(OrderContext context) { this.OrderDatabase = context; }
public UsersRepository(UserContext userContext, OrderContext orderContext, IMapper mapper) { this.userContext = userContext; this.orderContext = orderContext; this.mapper = mapper; }
public OrderItemRepository(OrderContext OrderContext) { this.OrderContext = OrderContext; }