public override IEnumerable<IDictionary<string, object>> RunQuery(SimpleQuery query, out IEnumerable<SimpleQueryClauseBase> unhandledClauses) { unhandledClauses = query.Clauses.AsEnumerable(); return GetTable(query.TableName); }
private void SetQueryContext(SimpleQuery query) { _query = query; _tableName = _schema.BuildObjectName(query.TableName); _table = _schema.FindTable(_tableName); var selectClause = _query.Clauses.OfType<SelectClause>().SingleOrDefault(); if (selectClause != null) { if (selectClause.Columns.OfType<AllColumnsSpecialReference>().Any()) { _columns = ExpandAllColumnsReferences(selectClause.Columns).ToArray(); } else { _columns = selectClause.Columns.ToArray(); } } else { _columns = _table.Columns.Select(c => ObjectReference.FromStrings(_table.Schema, _table.ActualName, c.ActualName)).ToArray(); } HandleWithClauses(); _whereCriteria = _query.Clauses.OfType<WhereClause>().Aggregate(SimpleExpression.Empty, (seed, where) => seed && where.Criteria); _havingCriteria = _query.Clauses.OfType<HavingClause>().Aggregate(SimpleExpression.Empty, (seed, having) => seed && having.Criteria); _commandBuilder.SetText(GetSelectClause(_tableName)); }
public void WhereShouldSetCriteria() { var query = new SimpleQuery(null, "foo"); var criteria = new SimpleExpression(1, 1, SimpleExpressionType.Equal); query = query.Where(criteria); Assert.AreSame(criteria, query.Clauses.OfType<WhereClause>().Single().Criteria); }
public void OrderByDescendingShouldSetOrderDescending() { var query = new SimpleQuery(null, "foo"); query = query.OrderByDescending(new ObjectReference("bar")); Assert.AreEqual("bar", query.Order.Single().Reference.GetName()); Assert.AreEqual(OrderByDirection.Descending, query.Order.Single().Direction); }
public void OrderByWithDescendingDirectionShouldSetOrderDescending() { var query = new SimpleQuery(null, "foo"); query = query.OrderBy(new ObjectReference("bar"), OrderByDirection.Descending); Assert.AreEqual("bar", query.Clauses.OfType<OrderByClause>().Single().Reference.GetName()); Assert.AreEqual(OrderByDirection.Descending, query.Clauses.OfType<OrderByClause>().Single().Direction); }
public void TakeShouldSetTakeCount() { var query = new SimpleQuery(null, "foo"); query = query.Take(42); Assert.IsNotNull(query.Clauses.OfType<TakeClause>().FirstOrDefault()); Assert.AreEqual(42, query.Clauses.OfType<TakeClause>().First().Count); }
public void OrderByBarShouldSetOrderAscending() { dynamic query = new SimpleQuery(null, "foo"); SimpleQuery actual = query.OrderByBar(); Assert.AreEqual("bar", actual.Clauses.OfType<OrderByClause>().Single().Reference.GetName().ToLowerInvariant()); Assert.AreEqual(OrderByDirection.Ascending, actual.Clauses.OfType<OrderByClause>().Single().Direction); }
private void SetQueryContext(SimpleQuery query) { _query = query; _tableName = ObjectName.Parse(query.TableName.Split('.').Last()); _table = _schema.FindTable(_tableName); _commandBuilder = new CommandBuilder(GetSelectClause(_tableName), _schema.SchemaProvider); }
public IEnumerable<IDictionary<string, object>> Find(MongoCollection<BsonDocument> collection, SimpleQuery query, out IEnumerable<SimpleQueryClauseBase> unhandledClauses) { var builder = MongoQueryBuilder.BuildFrom(query); unhandledClauses = builder.UnprocessedClauses; if (builder.IsTotalCountQuery) { long count; if (builder.Criteria == null) count = collection.Count(); else count = collection.Count(_expressionFormatter.Format(builder.Criteria)); //TODO: figure out how to make count a long builder.SetTotalCount((int)count); } if (!builder.SkipCount.HasValue && builder.TakeCount.HasValue && builder.TakeCount.Value == 1) return new[] { FindOne(collection, builder.Criteria) }; var cursor = CreateCursor(collection, builder.Criteria); ApplyFields(cursor, builder.Columns); ApplySorting(cursor, builder.Order); ApplySkip(cursor, builder.SkipCount); ApplyTake(cursor, builder.TakeCount); var aliases = builder.Columns.OfType<ObjectReference>().ToDictionary(x => ExpressionFormatter.GetFullName(x), x => x.GetAlias()); return cursor.Select(x => x.ToSimpleDictionary(aliases)); }
private static void GetErrors() { SimpleQuery p = new SimpleQuery { Site = NetworkSiteEnum.StackOverflow }; IBridgeResponseCollection<ApiException> errors = client.GetErrors(p); Console.WriteLine(errors.First().ErrorDescription); }
public override IEnumerable<IDictionary<string, object>> RunQuery(SimpleQuery query, out IEnumerable<SimpleQueryClauseBase> unhandledClauses) { unhandledClauses = Enumerable.Empty<SimpleQueryClauseBase>(); var criteria = query.Clauses.OfType<WhereClause>().Aggregate(SimpleExpression.Empty, (seed, where) => seed && where.Criteria); return Find(query.TableName, criteria); }
public IEnumerable<IDictionary<string, object>> RunQuery(SimpleQuery query, out IEnumerable<SimpleQueryClauseBase> unhandledClauses) { IEnumerable<IDictionary<string, object>> result; if (query.Clauses.OfType<WithCountClause>().Any()) return RunQueryWithCount(query, out unhandledClauses); ICommandBuilder[] commandBuilders = GetQueryCommandBuilders(query, out unhandledClauses); IDbConnection connection = _adapter.CreateConnection(); if (_adapter.ProviderSupportsCompoundStatements || commandBuilders.Length == 1) { result = CommandBuilder.CreateCommand( _adapter.ProviderHelper.GetCustomProvider<IDbParameterFactory>(_adapter.SchemaProvider), commandBuilders, connection).ToEnumerable(_adapter.CreateConnection); } else { result = commandBuilders.SelectMany(cb => cb.GetCommand(connection).ToEnumerable(_adapter.CreateConnection)); } if (query.Clauses.OfType<WithClause>().Any()) { result = new EagerLoadingEnumerable(result); } return result; }
public ICommandBuilder Build(SimpleQuery query) { var commandBuilder = new CommandBuilder(GetSelectClause(ObjectName.Parse(query.TableName)), _schema.SchemaProvider); if (query.Criteria != null) { commandBuilder.Append(" WHERE " + new ExpressionFormatter(commandBuilder, _schema).Format(query.Criteria)); } if (query.Order != null) { var orderNames = query.Order.Select(q => q.Reference.GetName() + (q.Direction == OrderByDirection.Descending ? " DESC" : string.Empty)); commandBuilder.Append(" ORDER BY " + string.Join(", ", orderNames)); } if (query.SkipCount != null || query.TakeCount != null) { var queryPager = _adoAdapter.ProviderHelper.GetCustomProvider<IQueryPager>(_adoAdapter.ConnectionProvider); if (queryPager == null) { throw new NotSupportedException("Paging is not supported by the current ADO provider."); } var skipTemplate = commandBuilder.AddParameter("skip", DbType.Int32, query.SkipCount ?? 0); var takeTemplate = commandBuilder.AddParameter("take", DbType.Int32, query.TakeCount ?? int.MaxValue); commandBuilder.SetText(queryPager.ApplyPaging(commandBuilder.Text, skipTemplate.Name, takeTemplate.Name)); } return commandBuilder; }
public object Execute(DataStrategy dataStrategy, SimpleQuery query, InvokeMemberBinder binder, object[] args) { var criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(query.TableName, CreateCriteriaDictionary(binder, args)); query = query.Where(criteriaExpression).Take(1); return query.FirstOrDefault(); }
public override IEnumerable<IDictionary<string, object>> Find(string tableName, SimpleExpression criteria) { var query = new SimpleQuery(this, tableName) .Where(criteria); IEnumerable<SimpleQueryClauseBase> unhandledClauses; return new MongoAdapterFinder(this, _expressionFormatter) .Find(GetCollection(tableName), query, out unhandledClauses); }
public void OrderByBarThenByQuuxShouldSetOrderAscending() { dynamic query = new SimpleQuery(null, "foo"); SimpleQuery actual = query.OrderByBar().ThenByQuux(); Assert.AreEqual("bar", actual.Order.First().Reference.GetName().ToLowerInvariant()); Assert.AreEqual("quux", actual.Order.Skip(1).First().Reference.GetName().ToLowerInvariant()); Assert.AreEqual(OrderByDirection.Ascending, actual.Order.First().Direction); Assert.AreEqual(OrderByDirection.Ascending, actual.Order.Skip(1).First().Direction); }
public object Execute(DataStrategy dataStrategy, SimpleQuery query, InvokeMemberBinder binder, object[] args) { var keyNames = dataStrategy.GetAdapter().GetKeyNames(query.TableName); var dict = keyNames.Select((k, i) => new KeyValuePair<string, object>(k, args[i])); query = query.Where(ExpressionHelper.CriteriaDictionaryToExpression(query.TableName, dict)).Take(1); var result = query.FirstOrDefault(); if (result == null) return null; return binder.Name.Equals("get", StringComparison.OrdinalIgnoreCase) ? result : ((IDictionary<string, object>) result).First().Value; }
public void OrderByBarThenQuxxShouldBeAbleToMixOrdering() { var query = new SimpleQuery(null, "foo"); query = query.OrderBy(new ObjectReference("bar"), OrderByDirection.Ascending) .ThenBy(new ObjectReference("quux"), OrderByDirection.Descending); Assert.AreEqual("bar", query.Clauses.OfType<OrderByClause>().First().Reference.GetName()); Assert.AreEqual("quux", query.Clauses.OfType<OrderByClause>().Skip(1).First().Reference.GetName()); Assert.AreEqual(OrderByDirection.Ascending, query.Clauses.OfType<OrderByClause>().First().Direction); Assert.AreEqual(OrderByDirection.Descending, query.Clauses.OfType<OrderByClause>().Skip(1).First().Direction); }
public void ThenByShouldModifyOrderAscending() { var query = new SimpleQuery(null, "foo"); query = query.OrderBy(new ObjectReference("bar")).ThenBy(new ObjectReference("quux")); var actual = query.Order.ToArray(); Assert.AreEqual(2, actual.Length); Assert.AreEqual("bar", actual[0].Reference.GetName()); Assert.AreEqual(OrderByDirection.Ascending, actual[0].Direction); Assert.AreEqual("quux", actual[1].Reference.GetName()); Assert.AreEqual(OrderByDirection.Ascending, actual[1].Direction); }
/// <summary> /// Executes the command. /// </summary> /// <param name="dataStrategy">The data strategy.</param> /// <param name="table"></param> /// <param name="binder">The binder from the <see cref="DynamicTable"/> method invocation.</param> /// <param name="args">The arguments from the <see cref="DynamicTable"/> method invocation.</param> /// <returns></returns> public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args) { var query = new SimpleQuery(dataStrategy, table.GetQualifiedName()); if (args.Length == 1 && args[0] is SimpleExpression) { query = query.Where((SimpleExpression)args[0]); } return query.Exists(); }
public IObservable<IDictionary<string, object>> RunQueryAsObservable(SimpleQuery query, out IEnumerable <SimpleQueryClauseBase> unhandledClauses) { IDbConnection connection = _adapter.CreateConnection(); return new QueryBuilder(_adapter).Build(query, out unhandledClauses) .GetCommand(connection, _adapter.AdoOptions) .ToObservable(connection, _adapter); }
public override IEnumerable<IDictionary<string, object>> RunQuery(SimpleQuery query, out IEnumerable<SimpleQueryClauseBase> unhandledClauses) { unhandledClauses = query.Clauses.Where(c => !(c is WhereClause)); var whereClauses = query.Clauses.OfType<WhereClause>().ToList(); if (whereClauses.Count == 0) { return Find(query.TableName, null); } return Find(query.TableName, query.Clauses.OfType<WhereClause>().DefaultIfEmpty().Select(w => w.Criteria).Aggregate((a, b) => a && b)); }
public ICommandBuilder Build(SimpleQuery query) { SetQueryContext(query); HandleJoins(); HandleQueryCriteria(); HandleGrouping(); HandleOrderBy(); HandlePaging(); return _commandBuilder; }
public ICommandBuilder Build(SimpleQuery query, out IEnumerable<SimpleQueryClauseBase> unhandledClauses) { _unhandledClauses = new List<SimpleQueryClauseBase>(); SetQueryContext(query); HandleJoins(); HandleQueryCriteria(); HandleGrouping(); HandleHavingCriteria(); HandleOrderBy(); unhandledClauses = _unhandledClauses; return _commandBuilder; }
public virtual async Task<Paged<Entities.Url>> GetResult(Filter.Simple.Data.Filter filter, int? accountId = null) { filter.Resource = "Urls"; DataStrategy strategy = Database.Open(); var query = new SimpleQuery(strategy, filter.Resource); var limit = _limit.Apply(filter); var skip = _skip.Apply(filter); dynamic accounts; query = query.Join(ObjectReference.FromString("Accounts"), JoinType.Inner, out accounts) .On(accounts.Id == new ObjectReference("AccountId", ObjectReference.FromString("Urls"))) .Select( new ObjectReference("Id", ObjectReference.FromString("Urls")), new ObjectReference("Address", ObjectReference.FromString("Urls")), new ObjectReference("Id", ObjectReference.FromString("Accounts")).As("Account_Id")) .Skip(_skip.Apply(filter)) .Take(_limit.Apply(filter)); if (accountId.HasValue) { var leftOperand = new ObjectReference("AccountId", ObjectReference.FromString("Urls")); query.Where(new SimpleExpression(leftOperand, accountId, SimpleExpressionType.Equal)); } if (filter.HasOrdering) { query = query.OrderBy(_order.Apply(filter), OrderByDirection.Ascending); } var data = await query.ToList<dynamic>(); var entities = AutoMapper.MapDynamic<Entities.Url>(data).ToList(); if (!entities.Any()) { return null; } return new Paged<Entities.Url> { Limit = limit, Skip = skip, Data = entities }; }
public QueryCommand BuildCommand(SimpleQuery query) { var cmd = ParseQuery(query); Table table; var formattedKeyValues = TryFormatExpressionAsKeyLookup(query.TableName, cmd.Criteria, _getKeyNames); bool isKeyLookup = !string.IsNullOrEmpty(formattedKeyValues); string clause = FormatTableClause(query.TableName, formattedKeyValues, out table); var commandText = clause; clause = FormatSpecialClause(table, cmd); if (!string.IsNullOrEmpty(clause)) { commandText += "/" + clause; cmd.IsScalarResult = true; } var clauses = new List<string>(); if (!isKeyLookup) { clause = FormatWhereClause(table, cmd); if (!string.IsNullOrEmpty(clause)) clauses.Add(clause); } clause = FormatWithClause(table, cmd); if (!string.IsNullOrEmpty(clause)) clauses.Add(clause); clause = FormatSkipClause(table, cmd); if (!string.IsNullOrEmpty(clause)) clauses.Add(clause); if (!isKeyLookup) { clause = FormatTakeClause(table, cmd); if (!string.IsNullOrEmpty(clause)) clauses.Add(clause); } clause = FormatOrderClause(table, cmd); if (!string.IsNullOrEmpty(clause)) clauses.Add(clause); clause = FormatSelectClause(table, cmd); if (!string.IsNullOrEmpty(clause)) clauses.Add(clause); clause = FormatCountClause(table, cmd); if (!string.IsNullOrEmpty(clause)) clauses.Add(clause); if (clauses.Count > 0) { commandText += "?" + string.Join("&", clauses); } cmd.CommandText = commandText; return cmd; }
private void Build(SimpleQuery query) { var unprocessedClauses = new Queue<SimpleQueryClauseBase>(query.Clauses); Func<SimpleQueryClauseBase, bool> processor; while (unprocessedClauses.Count > 0) { var clause = unprocessedClauses.Peek(); var clauseType = clause.GetType(); if (!_processors.TryGetValue(clauseType, out processor) || !processor(clause)) break; _processedClauses.Push(unprocessedClauses.Dequeue()); } UnprocessedClauses = unprocessedClauses; }
private IEnumerable<IDictionary<string, object>> RunQueryWithCount(SimpleQuery query, out IEnumerable<SimpleQueryClauseBase> unhandledClauses) { WithCountClause withCountClause; try { withCountClause = query.Clauses.OfType<WithCountClause>().First(); } catch (InvalidOperationException) { // Rethrow with meaning. throw new InvalidOperationException("No WithCountClause specified."); } query = query.ClearWithTotalCount(); var countQuery = query.ClearSkip() .ClearTake() .ClearOrderBy() .ClearWith() .ClearForUpdate() .ReplaceSelect(new CountSpecialReference()); var unhandledClausesList = new List<IEnumerable<SimpleQueryClauseBase>> { Enumerable.Empty<SimpleQueryClauseBase>(), Enumerable.Empty<SimpleQueryClauseBase>() }; using (var enumerator = RunQueries(new[] {countQuery, query}, unhandledClausesList).GetEnumerator()) { unhandledClauses = unhandledClausesList[1]; if (!enumerator.MoveNext()) { throw new InvalidOperationException(); } IDictionary<string, object> countRow = enumerator.Current.Single(); var value = countRow.First().Value; int count = value is int ? (int) value : Convert.ToInt32(value); withCountClause.SetCount(count); if (!enumerator.MoveNext()) { throw new InvalidOperationException(); } return enumerator.Current; } }
private static SearchRequest GetSearch() { var ssQuery = new SimpleQuery(); ssQuery.SearchTypes =new[]{new FederationNode{ Value = "Contact"} }; ssQuery.QueryString = "Jonas Syrstad"; ssQuery.GetNavigators = true; ssQuery.DetailLevel = "99"; var ssRequest = new SearchRequest { Query = ssQuery, Metadata = new RequestMetadata { RequestId = Guid.NewGuid().ToString(), ConfigSet = "1881.idefix.search.dev", SystemSource = "test" } }; return ssRequest; }
public QueryCommand BuildCommand(SimpleQuery query) { var cmd = new QueryCommand(); var unprocessedClauses = new Queue<SimpleQueryClauseBase>(query.Clauses); Func<SimpleQueryClauseBase, QueryCommand, bool> processor; while (unprocessedClauses.Count > 0) { var clause = unprocessedClauses.Peek(); var clauseType = clause.GetType(); if (!_processors.TryGetValue(clauseType, out processor) || !processor(clause, cmd)) break; cmd.ProcessedClauses.Push(unprocessedClauses.Dequeue()); } cmd.TablePath = query.TableName; cmd.UnprocessedClauses = unprocessedClauses; return cmd; }
public IEnumerable <IDictionary <string, object> > RunQuery(SimpleQuery query, IAdapterTransaction transaction, out IEnumerable <SimpleQueryClauseBase> unhandledClauses) { throw new NotImplementedException(); }
public override IObservable <IDictionary <string, object> > RunQueryAsObservable(SimpleQuery query, out IEnumerable <SimpleQueryClauseBase> unhandledClauses) { return(new AdoAdapterQueryRunner(this).RunQueryAsObservable(query, out unhandledClauses)); }
public override IEnumerable <IDictionary <string, object> > RunQuery(SimpleQuery query, out IEnumerable <SimpleQueryClauseBase> unhandledClauses) { return(FindByQuery(query, out unhandledClauses)); }
public void TestExceptionNotThrownWhenOverrideProvided() { var results = new SimpleQuery <ProductWithGuid>(Query, new ValueAndTypeTuple(NHibernateUtil.String, Key1.ToString()[0] + "%")).Execute(); Assert.That(results.Length, Is.EqualTo(1)); }
public TResult Deserialize <TResult>(SimpleQuery <TResult> query, string data) { return(Deserialize(query, JObject.Parse(data))); }
protected void Page_Load(object sender, EventArgs e) { try { string rid = Context.Request.Params["rid"]; rid = 782512 + ""; Range = new JObject(); points = new JArray(); if (string.IsNullOrEmpty(rid)) { return; } else { #region 查询数据 //查询线路信息 string hql = "SELECT NEW uf_CarGPS_WFRange(a.id,a.wfRequestId,a.sqr,a.ccqsrq,a.ccqssj,a.ccjzrq,a.ccjzsj,a.ccdd,a.Range,a.RangeCount,a.sqgs,a.sqbm)FROM uf_CarGPS_WFRange a WHERE wfRequestId=?"; SimpleQuery <uf_CarGPS_WFRange> GQuery = new SimpleQuery <uf_CarGPS_WFRange>(hql, Int32.Parse(rid)); uf_CarGPS_WFRange[] GBeans = GQuery.Execute(); if (GBeans.Length < 1) { return; } uf_CarGPS_WFRange GBean = GBeans[0]; //查询人员信息 hql = "SELECT NEW HrmResource(a.id,a.loginid,a.lastname)FROM HrmResource a WHERE a.id=?"; SimpleQuery <HrmResource> SQuery = new SimpleQuery <HrmResource>(hql, GBean.sqr); HrmResource[] UBeans = SQuery.Execute(); if (UBeans.Length == 0) { return; } //查询出线路信息 hql = "SELECT NEW uf_CarGPS_WFRoute(a.id,a.PointsCount,a.CreateTime,a.RouteRange,a.WFRangeID,a.Points)FROM uf_CarGPS_WFRoute a WHERE a.WFRangeID = ?"; SimpleQuery <uf_CarGPS_WFRoute> RQuery = new SimpleQuery <uf_CarGPS_WFRoute>(hql, GBean.id); uf_CarGPS_WFRoute[] RBeans = RQuery.Execute(); #endregion #region 封装数据 Range.Add("id", GBean.id); Range.Add("rid", GBean.wfRequestId); Range.Add("uName", UBeans[0].lastname); Range.Add("sqr", GBean.sqr); Range.Add("ccqsrq", GBean.ccqsrq); Range.Add("ccqssj", GBean.ccqssj); Range.Add("ccdd", GBean.ccdd); Range.Add("Range", GBean.Range); Range.Add("RangeCount", GBean.RangeCount); Range.Add("sqgs", GBean.sqgs); Range.Add("sqbm", GBean.sqbm); if (RBeans.Length > 0) { foreach (uf_CarGPS_WFRoute bean in RBeans) { JObject jo = new JObject(); jo.Add("id", bean.id); jo.Add("PointsCount", bean.PointsCount); jo.Add("CreateTime", bean.CreateTime); jo.Add("RouteRange", bean.RouteRange); jo.Add("WFRangeID", bean.WFRangeID); jo.Add("Points", bean.Points); points.Add(jo); } } #endregion #region 返回数据 //已经放在参数内 不需要返回 #endregion } } catch (Exception _e) { Log.Error("MapSearch:", _e); throw; } //根据流程id查询 uf_CarGPS_WFRange 和 uf_CarGPS_WFRange的明细 uf_CarGPS_WFRoute、 }
public MetroController(SimpleQuery simpleQuery) : base(simpleQuery) { }
public PetCareWorkingSkillController(SimpleQuery simpleQuery) : base(simpleQuery) { }
public PetCareEducationController(SimpleQuery simpleQuery) : base(simpleQuery) { }
public override IEnumerable <IDictionary <string, object> > RunQuery(SimpleQuery query) { throw new NotImplementedException(); }
private static void TestSimpleQuery() { var simpleQuery = new SimpleQuery <int>(); var query = from x in simpleQuery where x > 5 select x * 10; }
public ReligionController(SimpleQuery simpleQuery) : base(simpleQuery) { }
/* this needs to be abstracted too this can and should be able to search anything */ /// <summary> </summary> public static SortedDictionary <string, int> search_user_string(string term) { // Use hashtable to store name/value pairs SortedDictionary <string, int> results = new SortedDictionary <string, int>(); //id is for order int i = 0; // Trying a different Query method // Here was the all inclusive query (not used for now except for reference) /*String overallsqlstring = @"from place p where * p.abbrev_name LIKE :searchterm * or p.prime_name like :searchterm * or (p in (select p from p.tags as t where t.name like :searchterm)) * or (p in (select p from p.names as n where n.name like :searchterm)) * "; */ // Search place prime name String searchprime_name = @"SELECT u FROM users AS u WHERE u.display_name LIKE '%" + term + "%'"; SimpleQuery <appuser> pq = new SimpleQuery <appuser>(typeof(appuser), searchprime_name); appuser[] users = pq.Execute(); foreach (appuser user in users) { //results[i.ToString() + ":" + place.prime_name] = place.baseid; if (results.Any(item => item.Key.Split(':')[1].Trim() == user.display_name.Trim()) && results.Any(item => item.Value == user.baseid) ) { } else { results.Add(i.ToString() + ":" + user.display_name.Trim(), user.baseid); i++; } } // Search place abbrev String searchabbrev = @"from contact_profile u where u.first_name LIKE :searchterm OR u.last_name LIKE :searchterm OR u.email LIKE :searchterm AND u.isDefault=1 "; SimpleQuery <contact_profile> query = new SimpleQuery <contact_profile>(typeof(contact_profile), searchabbrev); query.SetParameter("searchterm", "%" + term + "%"); contact_profile[] profiles = query.Execute(); foreach (contact_profile profile in profiles) { //results[i.ToString()+":"+place.abbrev_name] = place.baseid; if (results.Any(item => item.Key.Split(':')[1].Trim() == profile.last_name + ", " + profile.first_name.Trim()) && results.Any(item => item.Value == profile.owner.baseid) ) { } else { results.Add(i.ToString() + ":" + profile.last_name + ", " + profile.first_name.Trim(), profile.owner.baseid); i++; } } return(results); }
public override IEnumerable <IDictionary <string, object> > RunQuery(SimpleQuery query, out IEnumerable <SimpleQueryClauseBase> unhandledClauses) { return(new MongoAdapterFinder(this, _expressionFormatter) .Find(GetCollection(query.TableName), query, out unhandledClauses)); }
private ICommandBuilder[] GetPagedQueryCommandBuilders(ref SimpleQuery query, out IEnumerable <SimpleQueryClauseBase> unhandledClauses) { return(GetPagedQueryCommandBuilders(ref query, -1, out unhandledClauses)); }
public IEnumerable <IDictionary <string, object> > RunQuery(SimpleQuery query, IAdapterTransaction transaction, out IEnumerable <SimpleQueryClauseBase> unhandledClauses) { return(new AdoAdapterQueryRunner(this, (AdoAdapterTransaction)transaction).RunQuery(query, out unhandledClauses)); }
public AboutNurseController(SimpleQuery simpleQuery) : base(simpleQuery) { }
public NannyWorkingSkillController(SimpleQuery simpleQuery) : base(simpleQuery) { }
IList <string> pids = null; // 父节点列表 #region ASP.NET 事件 protected void Page_Load(object sender, EventArgs e) { id = RequestData.Get <string>("id", String.Empty); ids = RequestData.GetList <string>("ids"); pids = RequestData.GetList <string>("pids"); SysGroup ent = null; switch (this.RequestAction) { case RequestActionEnum.Custom: if (RequestActionString == "querychildren") { if (String.IsNullOrEmpty(id)) { ents = SysGroup.FindAll("FROM SysGroup as ent WHERE ParentId is null and (Type = 2 or Type = 3) Order By SortIndex asc"); this.PageState.Add("DtList", ents); } else { string sql = @" select g.*,w.Id WId from SysGroup g left join WebPartTemplate w on g.GroupID=w.BaseTemplateId WHERE ParentId = '" + id + "' and (g.Type = 2 or g.Type = 3) Order By SortIndex asc"; DataHelper.QueryDictList(sql); //ents = SysGroup.FindAll("FROM SysGroup as ent WHERE g.ParentId = '" + id + "' and (Type = 2 or Type = 3) Order By SortIndex asc"); this.PageState.Add("DtList", DataHelper.QueryDictList(sql)); } } else if (RequestActionString == "batchdelete") { IList <object> idList = RequestData.GetList <object>("IdList"); if (idList != null && idList.Count > 0) { SysGroup.DoBatchDelete(idList.ToArray()); } } else if (RequestActionString == "c") { DoCreateSubByRole(); } else if (RequestActionString == "open") { if (id != "") { SimpleQuery query = new SimpleQuery(typeof(WebPartTemplate), "FROM WebPartTemplate WHERE BaseTemplateId='" + id + "' AND UserId IS NULL AND BlockType='DeptPortal'"); if (((WebPartTemplate[])WebPartTemplate.ExecuteQuery(query)).Length == 0) { query = new SimpleQuery(typeof(WebPartTemplate), "FROM WebPartTemplate WHERE Type IS NULL AND UserId IS NULL AND BlockType='Portal'"); WebPartTemplate wpT = ((WebPartTemplate[])WebPartTemplate.ExecuteQuery(query))[0]; WebPartTemplate wp = new WebPartTemplate(); wp.BaseTemplateId = wpT.Id; wp.Type = ""; wp.BlockType = "DeptPortal"; wp.BaseTemplateId = id; wp.IsDefault = "T"; wp.TemplateColWidth = wpT.TemplateColWidth; wp.TemplateString = ""; wp.TemplateXml = "<List></List>"; wp.GlobalColor = wpT.GlobalColor; wp.GlobalColorValue = wpT.GlobalColorValue; wp.Save(); } } } else if (RequestActionString == "close") { if (id != "") { WebPartTemplate wp = WebPartTemplate.FindAllByProperties(WebPartTemplate.Prop_BaseTemplateId, id)[0]; wp.Delete(); } } break; default: //SysGroup[] grpList = SysGroup.FindAll("From SysGroup as ent where ParentId is null and (Type = 2 or Type = 21) Order By SortIndex Desc"); string sqls = @" select g.*,w.Id WId from SysGroup g left join WebPartTemplate w on g.GroupID=w.BaseTemplateId where g.ParentId is null and (g.Type = 2 or g.Type = 21) Order By SortIndex Desc"; this.PageState.Add("DtList", DataHelper.QueryDictList(sqls)); break; } }
protected void BindLocalReport(MsLocalReport localReport, IReport report) { ILocalReportProcessingLocation location = (ILocalReportProcessingLocation)report.ReportProcessingLocation; localReport.LoadReportDefinition(ReportDefinitionCache.GetReportDefinition(location.File).GetReportStream()); localReport.EnableHyperlinks = true; localReport.EnableExternalImages = true; localReport.SetBasePermissionsForSandboxAppDomain(new System.Security.PermissionSet(System.Security.Permissions.PermissionState.Unrestricted)); //localReport.ExecuteReportInCurrentAppDomain(AppDomain.CurrentDomain.Evidence); //localReport.AddFullTrustModuleInSandboxAppDomain(new System.Security.Policy.StrongName(new System.Security.Permissions.StrongNamePublicKeyBlob(Nullable),"VB.Reports.App.ReportStyleLibrary.StyleSheet","1.0.0")); //localReport.AddTrustedCodeModuleInCurrentAppDomain(System.Reflection.Assembly.GetAssembly(typeof(VB.Reports.App.ReportStyleLibrary.StyleSheet)).ToString()); if (localReport.IsDrillthroughReport) { localReport.SetParameters(localReport.OriginalParametersToDrillthrough); } else { IList <MsReportParameter> parameters = new List <MsReportParameter>(); foreach (IReportParameter parameter in report.ReportParameters) { parameters.Add(new MsReportParameter(parameter.Name, GetParameterValue(parameter))); } localReport.SetParameters(parameters); } localReport.DataSources.Clear(); foreach (IReportDataCommandTemplate reportDataCommandTemplate in report.ReportDataCommandTemplates) { DictionaryDataParameterValue parameterValues = new DictionaryDataParameterValue(); foreach (IReportParameter parameter in reportDataCommandTemplate.Parameters) { if (localReport.IsDrillthroughReport) { parameterValues[parameter.Name] = GetParameterValue(parameter, localReport.OriginalParametersToDrillthrough); } else { parameterValues[parameter.Name] = GetParameterValue(parameter); } } using (IDataConnection connection = SimpleQuery.ConfigurationManagerConnection(location.DataSourceName)) { if (connection.State == ConnectionState.Closed) { connection.Open(); } using (IDataCommand command = connection.CreateCommand(reportDataCommandTemplate, parameterValues.DataParameterValue)) { command.CommandTimeout = 200; using (IDataReader reader = command.ExecuteReader()) { DataTable table = DataTableMapper.ToDataTable(reader); localReport.DataSources.Add(new MsReportDataSource(reportDataCommandTemplate.Name, table)); } } } } localReport.Refresh(); }
public override IEnumerable <IDictionary <string, object> > RunQuery(SimpleQuery query, out IEnumerable <SimpleQueryClauseBase> unhandledClauses) { throw new NotImplementedException(); }
public static Post FindLastestPost() { SimpleQuery <Post> q = new SimpleQuery <Post>(@"from Post p order by p.DateAdded desc"); return((Post)q.Execute()[0]); }
public static Post FindLatestPost() { var query = new SimpleQuery <Post>(@"from Post p order by p.DateAdded desc"); return(query.Execute()[0]); }
public NannyEducationController(SimpleQuery simpleQuery) : base(simpleQuery) { }
public AnimalTypeController(SimpleQuery simpleQuery) : base(simpleQuery) { }
public SaveLangResourceCommand(LangResourceValueQuery langResourceValueQuery, SimpleQuery simpleQuery, DbContext dbContext) { _langResourceValueQuery = langResourceValueQuery; _simpleQuery = simpleQuery; _dbContext = dbContext; }
private void IsianUnas_Load(object sender, EventArgs e) { cmb_tahunajaran.DataSource = SimpleQuery.get_listtahunajaran(); cmb_tahunajaran.DisplayMember = "TAHUN"; cmb_tahunajaran.ValueMember = "TAHUN"; }
public HousekeeperWorkingSkillController(SimpleQuery simpleQuery) : base(simpleQuery) { }
private static WebPartTemplate GetWebPartTemplateRecord(string userId, string userName, string blockType, string templateId, string isManage) { WebPartTemplate wp = null; if (!String.IsNullOrEmpty(blockType) && blockType != "Portal") { wp = WebPartTemplate.FindFirstByProperties("BlockType", blockType); if (HttpContext.Current.Request["DeptId"] != null && HttpContext.Current.Request["DeptId"].Trim() != "") { SimpleQuery query = new SimpleQuery(typeof(WebPartTemplate), "FROM WebPartTemplate WHERE BaseTemplateId='" + HttpContext.Current.Request["DeptId"] + "' AND UserId IS NULL AND BlockType='DeptPortal'"); if (((WebPartTemplate[])WebPartTemplate.ExecuteQuery(query)).Length == 0) { query = new SimpleQuery(typeof(WebPartTemplate), "FROM WebPartTemplate WHERE Type IS NULL AND UserId IS NULL AND BlockType='Portal'"); WebPartTemplate wpT = ((WebPartTemplate[])WebPartTemplate.ExecuteQuery(query))[0]; wp = new WebPartTemplate(); wp.BaseTemplateId = wpT.Id; wp.Type = ""; wp.BlockType = "DeptPortal"; wp.BaseTemplateId = HttpContext.Current.Request["DeptId"].Trim(); wp.IsDefault = "T"; wp.TemplateColWidth = wpT.TemplateColWidth; wp.TemplateString = ""; wp.TemplateXml = "<List></List>"; wp.GlobalColor = wpT.GlobalColor; wp.GlobalColorValue = wpT.GlobalColorValue; wp.Save(); } else { wp = ((WebPartTemplate[])WebPartTemplate.ExecuteQuery(query))[0]; } } } else { if (userId == "46c5f4df-f6d1-4b36-96ac-d39d3dd65a5d" || isManage == "T") { SimpleQuery query = new SimpleQuery(typeof(WebPartTemplate), "FROM WebPartTemplate WHERE Type IS NULL AND UserId IS NULL AND BlockType='Portal'"); wp = ((WebPartTemplate[])WebPartTemplate.ExecuteQuery(query))[0]; //wp = WebPartTemplate.FindAllByProperties("Type", "", "UserId", "", "BlockType", "Portal")[0]; } else { if (WebPartTemplate.Exists(" UserId=? and IsDefault='T' and BlockType=? and Type='User'", userId, "Portal") && isManage != "T") { wp = WebPartTemplate.FindAllByProperties("UserId", userId, "IsDefault", "T", "BlockType", "Portal")[0]; } else { SimpleQuery query = new SimpleQuery(typeof(WebPartTemplate), "FROM WebPartTemplate WHERE Type IS NULL AND UserId IS NULL AND BlockType='Portal'"); WebPartTemplate wpT = ((WebPartTemplate[])WebPartTemplate.ExecuteQuery(query))[0]; wp = new WebPartTemplate(); wp.BaseTemplateId = wpT.Id; wp.Type = "User"; wp.UserId = userId; wp.UserName = userName; wp.IsDefault = "T"; wp.TemplateColWidth = wpT.TemplateColWidth; wp.TemplateString = wpT.TemplateString; wp.TemplateXml = wpT.TemplateXml; wp.GlobalColor = wpT.GlobalColor; wp.GlobalColorValue = wpT.GlobalColorValue; wp.BlockType = wpT.BlockType; wp.Save(); } } //wp = WebPartTemplate.FindFirst(); } if (wp != null) { return(wp); } if (!String.IsNullOrEmpty(templateId)) { if (WebPartTemplate.Exists(" UserId=? and IsDefault='T' and BlockType=? and BaseTemplateId = ?", userId, templateId) && isManage != "T") { wp = WebPartTemplate.FindAllByProperties("UserId", userId, "IsDefault", "T", "BlockType", blockType, "BaseTemplateId", templateId)[0]; } else { WebPartBaseTemplate wpT = WebPartBaseTemplate.Find(templateId); wp = new WebPartTemplate(); wp.BaseTemplateId = wpT.Id; wp.Type = "User"; wp.UserId = userId; wp.UserName = ""; wp.IsDefault = "T"; wp.TemplateColWidth = wpT.TemplateColWidth; wp.TemplateString = wpT.TemplateString; wp.TemplateXml = wpT.TemplateXml; wp.GlobalColor = wpT.GlobalColor; wp.GlobalColorValue = wpT.GlobalColorValue; wp.BlockType = wpT.BlockType; wp.Save(); } } else { wp = WebPartTemplate.FindFirstByProperties("UserId", userId, "IsDefault", "T", "BlockType", blockType); } return(wp); }
private string GetQueryStatement() { _filterInfo = new SimpleQuery(); GenerateQueryInfo(); return(QueryRuleControl.GetFilterString(_filterInfo)); }