public void SignalSubscriptionSettingsUpdate(Int64 accountSlaveId, Int64 accountMasterId, ISubscribeSettings settings) { using (var db = GetDBConnect()) { Queryable.Where(db.signal_subscriptions, sub => sub.account_slave_id == accountSlaveId && sub.account_master_id == accountMasterId) .Set(p => p.subscription_type, (short)settings.SignalType) .Set(p => p.multiplier, settings.Multiplier) .Set(p => p.reverse, settings.Reverse) .Set(p => p.risk, settings.Risk) .Set(p => p.max_order_count, settings.MaxOrderCount) .Set(p => p.max_volume, settings.MaxVolume) .Set(p => p.order_type, (short)settings.OrdersType) .Set(p => p.status, (short)settings.Status) .Update(); var settingsVal = Enumerable.First(subscriptionCache.Filter(x => x.account_slave_id == accountSlaveId && x.account_master_id == accountMasterId)); settingsVal.subscription_type = (short)settings.SignalType; settingsVal.multiplier = settings.Multiplier; settingsVal.reverse = settings.Reverse; settingsVal.risk = settings.Risk; settingsVal.max_order_count = settings.MaxOrderCount; settingsVal.max_volume = settings.MaxVolume; settingsVal.order_type = (short)settings.OrdersType; settingsVal.status = (short)settings.Status; subscriptionCache.InsertOrUpdate(settingsVal.id, settingsVal); } }
public static T First <T>(this ImmutableArray <T> immutableArray) { // In the event of an empty array, generate the same exception // that the linq extension method would. return(immutableArray.Length > 0 ? immutableArray[0] : Enumerable.First(immutableArray.array)); }
public void BlinqShouldEqualLinqNativeArrayFirstPredicate([ArrayValues] int[] sourceArr) { var source = new NativeArray <int>(sourceArr, Allocator.Persistent); var expected = ExceptionAndValue(() => Linq.First(source, EqualsZero.Invoke)); var actual = ExceptionAndValue(() => source.First(EqualsZero)); AssertAreEqual(expected, actual); source.Dispose(); }
public void BlinqShouldEqualLinqNativeSequenceFirst([ArrayValues] int[] sourceArr) { var sourceNativeArr = new NativeArray <int>(sourceArr, Allocator.Persistent); var source = sourceNativeArr.ToValueSequence(); var expected = ExceptionAndValue(() => Linq.First(source)); var actual = ExceptionAndValue(() => source.First()); AssertAreEqual(expected, actual); sourceNativeArr.Dispose(); }
private void Update() { if (_grabbable.NearbyGrabbables.Count > 0 && !ghostObj.activeSelf) { var e = Enumerable.First(_grabbable.NearbyGrabbables).Value; ghostObj.SetActive(onlyAllow.Contains(e.name)); } else if (_grabbable.NearbyGrabbables.Count == 0 && ghostObj.activeSelf) { ghostObj.SetActive(false); } }
public void Unsubscribe(long slaveId, long masterId) { using (var db = GetDBConnect()) { Queryable.Where(db.signal_subscriptions, x => x.account_slave_id == slaveId && x.account_master_id == masterId) .Set(x => x.status, (short)SubscriptionStatus.Off) .Update(); var subscriptionVal = Enumerable.First(subscriptionCache.Filter(x => x.account_slave_id == slaveId && x.account_master_id == masterId)); subscriptionVal.status = (short)SubscriptionStatus.Off; subscriptionCache.InsertOrUpdate(subscriptionVal.id, subscriptionVal); } }
public void BlinqShouldEqualLinqNativeSequenceScheduleFirst([ArrayValues] int[] sourceArr) { using (var sourceNativeArr = new NativeArray <int>(sourceArr, Allocator.Persistent)) { var source = sourceNativeArr.ToValueSequence(); var expected = ExceptionAndValue(() => Linq.First(source)); if (expected.exception != null) { return; } var actual = ExceptionAndValue(() => source.ScheduleFirst().Complete()); AssertAreEqual(expected, actual); } }
public void BlinqShouldEqualLinqNativeSequenceRunFirstPredicate([ArrayValues] int[] sourceArr) { using (var sourceNativeArr = new NativeArray <int>(sourceArr, Allocator.Persistent)) { var source = sourceNativeArr.ToValueSequence(); var expected = ExceptionAndValue(() => Linq.First(source, EqualsZero.Invoke)); if (expected.exception != null) { return; } var actual = ExceptionAndValue(() => source.RunFirst(EqualsZero)); AssertAreEqual(expected, actual); } }
public void AddCommission(long slaveId, long masterId, decimal commission, int orderId) { using (var db = GetDBConnect()) { var subscriptionId = Enumerable.First(subscriptionCache.Filter(x => x.account_slave_id == slaveId && x.account_master_id == masterId)).id; db.Insert(new signal_commission { subscription_id = subscriptionId, amount = commission, date = DateTime.Now, order_id = orderId, is_accrued = false }); } }
public void Update_With_Tablock() { // Arrange const string sql = @"UPDATE Production.Product WITH (TABLOCK) SET ListPrice = ListPrice * 1.10 WHERE ProductNumber LIKE 'BK-%'; "; // Act var statement = Enumerable.First(ParserFactory.Execute <UpdateStatement>(sql)); // Assert Assert.IsNotNull(statement); Assert.IsNotEmpty(statement.TableHints); Assert.IsTrue(statement.TableHints.Count(th => th.Hint == "TABLOCK") == 1); }
public void Insert_With_Xlock() { // Arrange const string sql = @"INSERT INTO Production.Location WITH (XLOCK) (Name, CostRate, Availability) VALUES ( 'Final Inventory', 15, 80); "; // Act var statement = Enumerable.First(ParserFactory.Execute <InsertStatement>(sql)); // Assert Assert.IsNotNull(statement); Assert.IsNotEmpty(statement.TableHints); Assert.IsTrue(statement.TableHints.Where(x => x.Hint == "XLOCK").Count() == 1); }
public void Select_With_ForceSeek() { const string sql = @"SELECT * FROM Sales.SalesOrderHeader AS h INNER JOIN Sales.SalesOrderDetail AS d WITH (FORCESEEK) ON h.SalesOrderID = d.SalesOrderID WHERE h.TotalDue > 100 AND (d.OrderQty > 5 OR d.LineTotal < 1000.00);"; // Act var statement = Enumerable.First(ParserFactory.Execute <SelectStatement>(sql)); // Assert Assert.IsNotNull(statement); Assert.IsNotEmpty(statement.From); Assert.IsNotEmpty(statement.From[0].Joins); Assert.IsTrue(statement.From[0].Joins[0].TableHints.Where(x => x.Hint == "FORCESEEK").Count() == 1); }
public static TSource First <TSource>(this IEnumerable <TSource> source, Func <TSource, bool> predicate) => LinqEnumerable.First(source, predicate);
public static TSource First <TSource>(this IEnumerable <TSource> source) => LinqEnumerable.First(source);
public void LinqArray() { MakeMeasurement(() => Linq.First(source), "Linq").Run(); }