Beispiel #1
0
        public COASqlUpdateData <T> GenerateUpdateQuery(Expression <Func <T, bool> > where)
        {
            var SelectedList = new List <string>();
            var updateQuery  = new StringBuilder($"UPDATE {tableName} SET ");
            var properties   = Types.GenerateListOfProperties(GetProperties);

            properties.ForEach(property =>
            {
                if (!property.Equals(PrimaryKeyName))
                {
                    if (DataBaseType == COADataBaseTypes.Sql)
                    {
                        updateQuery.Append($"{property}=@{property},");
                    }
                    else
                    {
                        updateQuery.Append($"{property}=:{property},");
                    }
                    SelectedList.Add(property);
                }
            });

            updateQuery.Remove(updateQuery.Length - 1, 1);
            var wherestring = Types.PredicateToString(where, DataBaseType);

            updateQuery.Append(wherestring);
            return(new COASqlUpdateData <T>()
            {
                SqlQuery = updateQuery.ToString(), Lenght = updateQuery.ToString().Length, SelectedColumns = SelectedList, TableName = tableName, DataBaseType = DataBaseType, PrimaryKeyName = PrimaryKeyName, WhereQuery = wherestring
            });
        }
Beispiel #2
0
        /// <summary>
        /// This is search property for your datas
        /// </summary>
        public static COASqlSelectData <T> Where <T>(this COASqlSelectData <T> data, Expression <Func <T, bool> > Where)
        {
            var str = Types.PredicateToString(Where, data.DataBaseType);

            data.SqlQuery  += str;
            data.WhereQuery = str;
            data.Lenght     = data.SqlQuery.Length;
            return(data);
        }