Example #1
0
        /// <summary>
        /// Get all <see cref="Messages"/> From The Forum
        /// </summary>
        /// <returns>
        /// Message List
        /// </returns>
        public static List <Messages> YafDnnGetMessages()
        {
            var messagesList = new List <Messages>();

            using (var cmd = DbHelpers.GetCommand("YafDnn_Messages"))
            {
                cmd.CommandType = CommandType.StoredProcedure;

                var mesagesTable = LegacyDb.DbAccess.GetData(cmd);

                messagesList.AddRange(
                    from DataRow row in mesagesTable.Rows
                    select
                    new Messages
                {
                    Message   = row["Message"].ToType <string>(),
                    MessageId = row["MessageID"].ToType <int>(),
                    TopicId   = row["TopicID"].ToType <int>(),
                    Posted    = row["Posted"].ToType <DateTime>()
                });
            }

            return(messagesList);
        }
Example #2
0
        /// <summary>
        /// Get all <see cref="Messages"/> From The Forum
        /// </summary>
        /// <returns>
        /// Topics List
        /// </returns>
        public static List <Topics> YafDnnGetTopics()
        {
            var topicsList = new List <Topics>();

            using (var cmd = DbHelpers.GetCommand("YafDnn_Topics"))
            {
                cmd.CommandType = CommandType.StoredProcedure;

                var topicsTable = LegacyDb.DbAccess.GetData(cmd);

                topicsList.AddRange(
                    from DataRow row in topicsTable.Rows
                    select
                    new Topics
                {
                    TopicName = row["Topic"].ToType <string>(),
                    TopicId   = row["TopicID"].ToType <int>(),
                    ForumId   = row["ForumID"].ToType <int>(),
                    Posted    = row["Posted"].ToType <DateTime>()
                });
            }

            return(topicsList);
        }
Example #3
0
        public DbConnection CreateConnection(string nameOrConnectionString)
        {
            Check.NotEmpty(nameOrConnectionString, "nameOrConnectionString");

            // If the "name or connection string" contains an '=' character then it is treated as a connection string.
            var connectionString = nameOrConnectionString;

            if (!DbHelpers.TreatAsConnectionString(nameOrConnectionString))
            {
                if (nameOrConnectionString.EndsWith(".mdf", ignoreCase: true, culture: null))
                {
                    throw Error.SqlConnectionFactory_MdfNotSupported(nameOrConnectionString);
                }

                connectionString =
                    new SqlConnectionStringBuilder(BaseConnectionString)
                {
                    InitialCatalog = nameOrConnectionString
                }.ConnectionString;
            }

            DbConnection connection = null;

            try
            {
                connection = ProviderFactory("System.Data.SqlClient").CreateConnection();
                connection.ConnectionString = connectionString;
            }
            catch
            {
                // Fallback to hard-coded type if provider didn't work
                connection = new SqlConnection(connectionString);
            }

            return(connection);
        }
        private IQueryable <T> FromSQLRAWWithParams <T>(string sql, params SqlParameter[] parameters) where T : class
        {
            string query = DbHelpers.GetQuery(sql, parameters);

            return(this.Query <T>().FromSqlRaw(query, parameters));
        }
        public DbPropertyEntry <TEntity, TProperty> Property <TProperty>(Expression <Func <TEntity, TProperty> > property)
        {
            Check.NotNull(property, "property");

            return(Property <TProperty>(DbHelpers.ParsePropertySelector(property, "Property", "property")));
        }
Example #6
0
 private void MenuItem_Click_10(object sender, RoutedEventArgs e)
 {
     DataTextBox.Text = DbHelpers.Gengers2string();
 }
Example #7
0
 private void MenuItem_Click_4(object sender, RoutedEventArgs e)
 {
     DataTextBox.Text = DbHelpers.Counties2string();
 }
 /// <summary>
 ///     Returns a new query where the entities returned will not be cached in the <see cref="DbContext" />.
 /// </summary>
 /// <returns> A new query with NoTracking applied. </returns>
 public virtual IInternalQuery <TElement> AsNoTracking()
 {
     return(new InternalQuery <TElement>(
                _internalContext, (ObjectQuery)DbHelpers.CreateNoTrackingQuery(_objectQuery)));
 }
Example #9
0
 public virtual IInternalQuery <TElement> WithExecutionStrategy(
     IDbExecutionStrategy executionStrategy)
 {
     return((IInternalQuery <TElement>) new InternalQuery <TElement>(this._internalContext, (System.Data.Entity.Core.Objects.ObjectQuery)DbHelpers.CreateQueryWithExecutionStrategy((System.Data.Entity.Core.Objects.ObjectQuery) this._objectQuery, executionStrategy)));
 }
Example #10
0
 public virtual void GlobalSetup()
 {
     using var sqlConnection = DbHelpers.OpenSqlConnection();
     DbHelpers.TruncateTable <DomainEntity>(sqlConnection);
 }
Example #11
0
 /// <summary>
 /// Saves the hash of a password
 /// </summary>
 /// <param name="pwd"></param>
 public void SetPassword(string pwd)
 {
     Password           = DbHelpers.CreateMD5(Userid + pwd);
     LastPasswordModify = DateTime.Now;
 }
Example #12
0
 /// <summary>
 /// Checks a password against its saved hash
 /// </summary>
 /// <param name="pwd"></param>
 /// <returns></returns>
 public bool CheckPassword(string pwd) => Password == DbHelpers.CreateMD5(Userid + pwd);
Example #13
0
 public DbPropertyEntry <TEntity, TNestedProperty> Property <TNestedProperty>(
     Expression <Func <TComplexProperty, TNestedProperty> > property)
 {
     Check.NotNull <Expression <Func <TComplexProperty, TNestedProperty> > >(property, nameof(property));
     return(this.Property <TNestedProperty>(DbHelpers.ParsePropertySelector <TComplexProperty, TNestedProperty>(property, nameof(Property), nameof(property))));
 }
 public SettingsController(IConfigurationRoot configuration)
 {
     Configuration = configuration;
     Db            = DbHelpers.OpenDbConnection(Configuration);
 }
Example #15
0
 public ActionResult Create()
 {
     ViewBag.Countries = DbHelpers.GetCountriesToList();
     return(View());
 }
Example #16
0
        public void ShouldHandleEmptyArray()
        {
            var result = DbHelpers.SplitIds(new int[] { });

            result.Length.Should().Be(0);
        }
Example #17
0
 public virtual IInternalQuery <TElement> AsStreaming()
 {
     return((IInternalQuery <TElement>) new InternalQuery <TElement>(this._internalContext, (System.Data.Entity.Core.Objects.ObjectQuery)DbHelpers.CreateStreamingQuery((System.Data.Entity.Core.Objects.ObjectQuery) this._objectQuery)));
 }
Example #18
0
 public AccountController(DbHelpers dbhelpers, ApplicationUserManager userManager, ApplicationSignInManager signInManager)
 {
     _dbhelpers    = dbhelpers;
     UserManager   = userManager;
     SignInManager = signInManager;
 }
Example #19
0
 public virtual IInternalQuery <TElement> WithExecutionStrategy(IDbExecutionStrategy executionStrategy)
 {
     return(new InternalQuery <TElement>(
                _internalContext, (ObjectQuery)DbHelpers.CreateQueryWithExecutionStrategy(_objectQuery, executionStrategy)));
 }
Example #20
0
 public ActionResult Portal()
 {
     return(View(DbHelpers.GetTestsByUserName(User.Identity.Name)));
 }
Example #21
0
 private void MenuItem_Click_2(object sender, RoutedEventArgs e)
 {
     DataTextBox.Text = DbHelpers.Languages2string();
 }
Example #22
0
 public ActionResult Sessions()
 {
     return(View(DbHelpers.GetSessions()));
 }
Example #23
0
 private void MenuItem_Click_8(object sender, RoutedEventArgs e)
 {
     DataTextBox.Text = DbHelpers.Editions2string();
 }
Example #24
0
 public JsonResult ClearSessions(int SessionId)
 {
     DbHelpers.RemoveSession(SessionId);
     return(Json(true, JsonRequestBehavior.AllowGet));
 }
Example #25
0
        /// <summary>
        /// The set profile properties.
        /// </summary>
        /// <param name="appName">
        /// The app name.
        /// </param>
        /// <param name="userID">
        /// The user id.
        /// </param>
        /// <param name="values">
        /// The values.
        /// </param>
        /// <param name="settingsColumnsList">
        /// The settings columns list.
        /// </param>
        public void SetProfileProperties([NotNull] object appName, [NotNull] object userID,
                                         [NotNull] SettingsPropertyValueCollection values, [NotNull] List <SettingsPropertyColumn> settingsColumnsList)
        {
            using (var cmd = new SqlCommand())
            {
                string table = DbHelpers.GetObjectName("prov_Profile");

                StringBuilder sqlCommand = new StringBuilder("IF EXISTS (SELECT 1 FROM ").Append(table);
                sqlCommand.Append(" WHERE UserId = @UserID) ");
                cmd.Parameters.AddWithValue("@UserID", userID);

                // Build up strings used in the query
                var columnStr = new StringBuilder();
                var valueStr  = new StringBuilder();
                var setStr    = new StringBuilder();
                int count     = 0;

                foreach (SettingsPropertyColumn column in settingsColumnsList)
                {
                    // only write if it's dirty
                    if (values[column.Settings.Name].IsDirty)
                    {
                        columnStr.Append(", ");
                        valueStr.Append(", ");
                        columnStr.Append(column.Settings.Name);
                        string valueParam = "@Value" + count;
                        valueStr.Append(valueParam);
                        cmd.Parameters.AddWithValue(valueParam, values[column.Settings.Name].PropertyValue);

                        if (column.DataType != SqlDbType.Timestamp)
                        {
                            if (count > 0)
                            {
                                setStr.Append(",");
                            }

                            setStr.Append(column.Settings.Name);
                            setStr.Append("=");
                            setStr.Append(valueParam);
                        }

                        count++;
                    }
                }

                columnStr.Append(",LastUpdatedDate ");
                valueStr.Append(",@LastUpdatedDate");
                setStr.Append(",LastUpdatedDate=@LastUpdatedDate");
                cmd.Parameters.AddWithValue("@LastUpdatedDate", DateTime.UtcNow);

                sqlCommand.Append("BEGIN UPDATE ").Append(table).Append(" SET ").Append(setStr.ToString());
                sqlCommand.Append(" WHERE UserId = '").Append(userID.ToString()).Append("'");

                sqlCommand.Append(" END ELSE BEGIN INSERT ")
                .Append(table)
                .Append(" (UserId")
                .Append(columnStr.ToString());
                sqlCommand.Append(") VALUES ('")
                .Append(userID.ToString())
                .Append("'")
                .Append(valueStr.ToString())
                .Append(
                    ") END");

                cmd.CommandText = sqlCommand.ToString();
                cmd.CommandType = CommandType.Text;

                this.DbAccess.ExecuteNonQuery(cmd);
            }
        }
Example #26
0
        public ActionResult TestDetails(String TestId)
        {
            var model = DbHelpers.GetTestById(Int32.Parse(TestId), true);

            return(View(model));
        }
Example #27
0
 private void InitializeUnderlyingTypes(EntitySetTypePair pair)
 {
     this._entitySet           = pair.EntitySet;
     this._baseType            = pair.BaseType;
     this._entitySetName       = string.Format((IFormatProvider)CultureInfo.InvariantCulture, "{0}.{1}", (object)this._entitySet.EntityContainer.Name, (object)this._entitySet.Name);
     this._quotedEntitySetName = string.Format((IFormatProvider)CultureInfo.InvariantCulture, "{0}.{1}", (object)DbHelpers.QuoteIdentifier(this._entitySet.EntityContainer.Name), (object)DbHelpers.QuoteIdentifier(this._entitySet.Name));
     this.InitializeQuery(this.CreateObjectQuery(false, new bool?(), (IDbExecutionStrategy)null));
 }
Example #28
0
 public ActionResult GetSessions()
 {
     return(View(new GridModel <Session>(DbHelpers.GetSessions())));
 }
        private IQueryable <T> FromSQLRAWWithOutParams <T>(string sql) where T : class
        {
            string query = DbHelpers.GetQuery(sql);

            return(this.Query <T>().FromSqlRaw(query));
        }
Example #30
0
        public ActionResult GetSamples(int TestId)
        {
            var model = DbHelpers.GetTestById(TestId, true).Samples;

            return(View(new GridModel <Sample>(model)));
        }