/// <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); }
/// <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); }
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"))); }
private void MenuItem_Click_10(object sender, RoutedEventArgs e) { DataTextBox.Text = DbHelpers.Gengers2string(); }
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))); }
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))); }
public virtual void GlobalSetup() { using var sqlConnection = DbHelpers.OpenSqlConnection(); DbHelpers.TruncateTable <DomainEntity>(sqlConnection); }
/// <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; }
/// <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);
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); }
public ActionResult Create() { ViewBag.Countries = DbHelpers.GetCountriesToList(); return(View()); }
public void ShouldHandleEmptyArray() { var result = DbHelpers.SplitIds(new int[] { }); result.Length.Should().Be(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))); }
public AccountController(DbHelpers dbhelpers, ApplicationUserManager userManager, ApplicationSignInManager signInManager) { _dbhelpers = dbhelpers; UserManager = userManager; SignInManager = signInManager; }
public virtual IInternalQuery <TElement> WithExecutionStrategy(IDbExecutionStrategy executionStrategy) { return(new InternalQuery <TElement>( _internalContext, (ObjectQuery)DbHelpers.CreateQueryWithExecutionStrategy(_objectQuery, executionStrategy))); }
public ActionResult Portal() { return(View(DbHelpers.GetTestsByUserName(User.Identity.Name))); }
private void MenuItem_Click_2(object sender, RoutedEventArgs e) { DataTextBox.Text = DbHelpers.Languages2string(); }
public ActionResult Sessions() { return(View(DbHelpers.GetSessions())); }
private void MenuItem_Click_8(object sender, RoutedEventArgs e) { DataTextBox.Text = DbHelpers.Editions2string(); }
public JsonResult ClearSessions(int SessionId) { DbHelpers.RemoveSession(SessionId); return(Json(true, JsonRequestBehavior.AllowGet)); }
/// <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); } }
public ActionResult TestDetails(String TestId) { var model = DbHelpers.GetTestById(Int32.Parse(TestId), true); return(View(model)); }
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)); }
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)); }
public ActionResult GetSamples(int TestId) { var model = DbHelpers.GetTestById(TestId, true).Samples; return(View(new GridModel <Sample>(model))); }