示例#1
0
        public QueryContext <T> GetQueryContext(T item)
        {
            ISqlBuilder <T>   builder  = new InsertSqlBuilder <T>(item);
            QueryDirector <T> director = new QueryDirector <T>(builder);

            return(director.GetDataContext());
        }
示例#2
0
        public List <EventCustomer> Search(SearchRequestDTO input, int from, int size)
        {
            List <QueryContainer> container = new QueryDirector().CreateQuery(input);
            ISearchRequest        request   = new SearchRequest <EventCustomer>()
            {
                Query = new BoolQuery()
                {
                    Must = container
                },
                From = from,
                Size = size
            };

            var result = client.Value.Search <EventCustomer>(request).Documents.ToList();

            return(result);
        }
示例#3
0
        public void ExcuteInsertCommand <B>(B aEntity, string con) where B : EntityBase, new()
        {
            aEntity.CreatedDate = GeneralUtility.ConvertSystemDateStringFormat(System.DateTime.Now);

            SqlConnection l_Connection = new SqlConnection(con);

            SqlCommand l_Command = new SqlCommand();

            l_Command.Connection = l_Connection;

            var l_InsertQuery = new InsertSqlBuilder <B>(aEntity);

            QueryDirector <B> l_Construct = new QueryDirector <B>(l_InsertQuery);

            var l_Context = l_Construct.GetDataContext();

            l_Command.CommandTimeout = 0;


            l_Command.CommandText = l_Context.mSQL;

            foreach (var l_SQLParameters in l_Context.mSQLParameters)
            {
                l_Command.Parameters.Add(l_SQLParameters);
            }

            try
            {
                l_Connection.Open();

                l_Command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                l_Connection.Close();
            }
        }
示例#4
0
        public void ExcuteUpdateCommand <B>(B aEntity, string con) where B : EntityBase, new()
        {
            SqlConnection l_Connection = new SqlConnection(con);

            SqlCommand l_Command = new SqlCommand();

            l_Command.Connection = l_Connection;

            var l_QueryBuilder = new UpdateSQLBuilder <B>(aEntity);

            QueryDirector <B> l_Construct = new QueryDirector <B>(l_QueryBuilder);

            var l_Context = l_Construct.GetDataContext();

            l_Command.CommandText = l_Context.mSQL;

            foreach (var l_SQLParameters in l_Context.mSQLParameters)
            {
                l_Command.Parameters.Add(l_SQLParameters);
            }

            try
            {
                l_Connection.Open();

                l_Command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                l_Connection.Close();
            }
        }