// internal constructor that takes mocks for unit tests.
 internal LinqDataSourceView(LinqDataSource owner, string name, HttpContext context,
                             IDynamicQueryable dynamicQueryable, ILinqToSql linqToSql)
     : base(owner, name, context, dynamicQueryable) {
     _context = context;
     _owner = owner;
     _linqToSql = linqToSql;
 }
        public void FillProfile()
        {
            LinqDataSource matchesForProfileLinQ = new LinqDataSource();
            matchesForProfileLinQ.ContextTypeName = "SoccerServerV1.SoccerDataModelDataContext";
            matchesForProfileLinQ.TableName = "Matches";
            matchesForProfileLinQ.OrderBy = "MatchID desc";
            matchesForProfileLinQ.Where = "MatchParticipations.Any(TeamID == " + mTeamID + ")";
            MyProfileMatches.DataSource = matchesForProfileLinQ;

            MyPlayerName.Text = "Player name: " + mPlayer.Name + " " + mPlayer.Surname;
            MyTeamName.Text = "Team Name: " + mPlayer.Team.Name;
            MyDateCreated.Text = "Date created: " + mPlayer.CreationDate.ToString();
            MyLiked.Text = "Liked: " + mPlayer.Liked.ToString();
            MyNumSessions.Text = "Sessions: " + GetNumSessions().ToString();
            MyTrueSkill.Text = "TrueSkill " + GetTrueSkill().ToString();
            MyXP.Text = "XP: " + mPlayer.Team.XP.ToString();
            MySkillPoints.Text = "SkillPoints: " + mPlayer.Team.SkillPoints.ToString();
            MyFitness.Text = "Fitness: " + mPlayer.Team.Fitness.ToString();

            string specialTrainings = "";
            foreach(var training in mPlayer.Team.SpecialTrainings)
            {
                specialTrainings += training.SpecialTrainingDefinition.Name + "/";
            }
            MySpecialTrainings.Text = "SpecialTrainings: " + specialTrainings.TrimEnd('/');
        }
        /// <summary>
        /// Creates a new instance of <see cref="LinqDataSource"/> with the same properties as the
        /// given <see cref="LinqDataSource"/>.
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public static LinqDataSource Clone(this LinqDataSource source)
        {
            Contract.Requires<ArgumentNullException>(source != null, "source is null.");

            var result = new LinqDataSource
            {
                ContextTypeName = source.ContextTypeName,
                TableName = source.TableName,
                EnableDelete = source.EnableDelete,
                EnableInsert = source.EnableInsert,
                EnableUpdate = source.EnableUpdate,
                Where = source.Where
            };

            foreach (Parameter parameter in source.WhereParameters)
            {
                result.WhereParameters.Add(parameter);
            }

            return result;
        }
        //TODO: Unit Test
        /// <summary>
        /// Creates a new instance of <see cref="LinqDataSource"/> with the same properties as the
        /// given <see cref="LinqDataSource"/>.
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public static LinqDataSource Clone(this LinqDataSource source)
        {
            // Pre-conditions
            if (source == null)
                throw new ArgumentNullException("source", "source is null");

            LinqDataSource result = new LinqDataSource
            {
                ContextTypeName = source.ContextTypeName,
                TableName = source.TableName,
                EnableDelete = source.EnableDelete,
                EnableInsert = source.EnableInsert,
                EnableUpdate = source.EnableUpdate,
                Where = source.Where
            };

            foreach (Parameter parameter in source.WhereParameters)
                result.WhereParameters.Add(parameter);

            return result;
        }
 public LinqDataSourceView(LinqDataSource owner, string name, HttpContext context)
     : this(owner, name, context, new DynamicQueryableWrapper(), new LinqToSqlWrapper())
 {
 }
Beispiel #6
0
		public LinqDataSourceView (LinqDataSource owner, string name, HttpContext context)
			: base (owner, name)
		{
			source = owner;
		}
 public LinqDataSourceView(LinqDataSource owner, string name, HttpContext context)
     : base(owner, name)
 {
     source = owner;
 }
		public void DynamicDataExtensions_GetTable_Test3()
		{
			HttpContext.Current = new HttpContext(new FakeWorkerRequest());
			var dds = new LinqDataSource();

			dds.GetTable();
		}
 public LinqDataSourceView(LinqDataSource owner, string name, HttpContext context)
     : this(owner, name, context, new DynamicQueryableWrapper(), new LinqToSqlWrapper()) {
 }
        private void BuildMenu(DevExpress.Web.ASPxMenu.ASPxMenu menu, LinqDataSource dataSource)
        {
            m_MenuItems = new Dictionary<string, DevExpress.Web.ASPxMenu.MenuItem>();
			m_MenuUrls = new Dictionary<DevExpress.Web.ASPxMenu.MenuItem, string>();
            List<MenuItem> itemList = MenuList;

            foreach (MenuItem mItem in itemList)
            {
                DevExpress.Web.ASPxMenu.MenuItem item = CreateMenuItem(mItem.Description, mItem.Url);
                
                if (m_MenuItems.ContainsKey(mItem.ParentMenuID.ToString()))
                    m_MenuItems[mItem.ParentMenuID.ToString()].Items.Add(item);
                else
                {
                    if (mItem.ParentMenuID == 0)
                        menu.Items.Add(item);
                }

                m_MenuUrls.Add(item, mItem.Url);

                m_MenuItems.Add(mItem.MenuID.ToString(), item);
            }
        }
        protected void PatternMatching()
        {
            string StringForWhere  = "AveragePrice >= MinPrice && Average <= MaxPrice";
            int counter = new int();
            if (TypeForSearch != 0)
            {
                StringForWhere += " && ";
            }

            LinqDataSource quer = new LinqDataSource();
            quer.TableName = "Tour";
            quer.ID = "LinqDataSource1";
            //quer.Where;
            using(var context = new TravelDBEntities())
            {
                if (MaxPrice == 0)
                {
                    MinPrice = 0;
                    MaxPrice = 100500;
                }
                var list = from item in context.Tour
                           where item.AveragePrice >= MinPrice && item.MinimalPrice <= MaxPrice
                           select item.IDTour;
                foreach (int a in list) //checking up results
                {
                    counter++;
                //    str = TextBox1.Text;
                //    str += a.ToString();
                //    TextBox1.Text = str;
                }
                if (counter == 0)
                {
                    //there are no results, too strict requirements      i need message about it
                    return;
                }
                else _quantity = counter;
            }
            MaxPrice = 0;
            Refresh();
        }