Beispiel #1
0
        /// <summary>	Gets by identifier statement. </summary>
        /// <param name="type">	The type. </param>
        /// <returns>	The by identifier statement. </returns>
        public virtual string GetByKeyStatement(Type type)
        {
            var key = SqlCache.TypeKeyPropertiesCache(type).Single();

            return
                ($"SELECT {RenderPropertyList(SqlCache.TypePropertiesChache(type).ToArray())} FROM {RenderTableName(type)} WHERE {RenderPropertyName(key)} = {RenderParameterProperty(key)}");
        }
Beispiel #2
0
        /// <summary>	Gets delete statememt. </summary>
        /// <param name="type">	The type. </param>
        /// <returns>	The delete statememt. </returns>
        public virtual string GetDeleteStatememt(Type type)
        {
            var key = SqlCache.TypeKeyPropertiesCache(type).Single();

            return
                ($"DELETE FROM {RenderTableName(type)} WHERE {RenderPropertyName(key)} = {RenderParameterProperty(key)}");
        }
Beispiel #3
0
        /// <summary>	Gets insert automatic key statement. </summary>
        /// <param name="type">	The type. </param>
        /// <returns>	The insert automatic key statement. </returns>
        public virtual string GetInsertAutoKeyStatement(Type type)
        {
            var key           = SqlCache.TypeKeyPropertiesCache(type).Single();
            var columnList    = RenderAutoKeyColumnList(type).ToString();
            var parameterList = RenderAutoKeyParameterList(type).ToString();

            return
                ($"INSERT INTO {RenderTableName(type)} ({columnList}) VALUES ({parameterList}){GetAutoKeyStatement(key)}");
        }
Beispiel #4
0
        /// <summary>	Gets update statement. </summary>
        /// <param name="type">	The type. </param>
        /// <returns>	The update statement. </returns>
        public virtual string GetUpdateStatement(Type type)
        {
            var key        = SqlCache.TypeKeyPropertiesCache(type).Single();
            var setClauses = RenderSetStatements(type).ToString();

            return
                ($"UPDATE {RenderTableName(type)} " +
                 $"SET {setClauses} " +
                 $"WHERE {RenderPropertyName(key)} = {RenderParameterProperty(key)}");
        }
Beispiel #5
0
        /// <summary>	Gets key parameter. </summary>
        /// <param name="type">	The type. </param>
        /// <returns>	The key parameter. </returns>
        public virtual string GetKeyParameter(Type type)
        {
            var key = SqlCache.TypeKeyPropertiesCache(type).Single();

            return(RenderParameterProperty(key));
        }
Beispiel #6
0
 /// <summary>	Gets the columns without keys in this collection. </summary>
 /// <param name="type">	The type. </param>
 /// <returns>
 ///     An enumerator that allows foreach to be used to process the columns without keys in this
 ///     collection.
 /// </returns>
 public virtual IEnumerable <PropertyInfo> GetPropertiesWithoutKey(Type type)
 {
     return(SqlCache.TypePropertiesChache(type).Except(new[] { SqlCache.TypeKeyPropertiesCache(type).Single() }));
 }