Beispiel #1
0
        public static LolitaSetting <TEntity> WithSQL <TEntity, TProperty>(this LolitaValuing <TEntity, TProperty> self, Func <string, ISqlGenerationHelper, string> sql, params object[] parameters)
            where TEntity : class, new()
        {
            if (sql == null)
            {
                throw new ArgumentNullException("Sql expression cannot be null.");
            }

            var field = self.CurrentField;
            var sqlGenerationHelper = self.Inner.GetService <ISqlGenerationHelper>();
            var _sql = sql(field, sqlGenerationHelper);

            var paramCnt = self.Inner.Parameters.Count;

            if (parameters != null && parameters.Length > 0)
            {
                for (var i = 0; i < parameters.Length; i++)
                {
                    _sql = _sql.Replace("{" + i + "}", "{" + (i + paramCnt) + "}");
                    self.Inner.Parameters.Add(parameters[i]);
                }
            }
            var field_info = new SetFieldInfo {
                Field = self.CurrentField, Index = -1, Type = "WithSQL", Value = _sql
            };
            var factory = self.GetService <ISetFieldSqlGenerator>();

            self.Inner.Operations.Add(factory.TranslateToSql(field_info));
            return(self.Inner);
        }
Beispiel #2
0
        private static LolitaSetting <TEntity> valuing <TEntity, TProperty>(this LolitaValuing <TEntity, TProperty> self, string type, object value)
            where TEntity : class, new()
        {
            var factory = self.GetService <ISetFieldSqlGenerator>();

            self.Inner.Parameters.Add(value);
            var sql = factory.TranslateToSql(new SetFieldInfo {
                Field = self.CurrentField, Index = self.Inner.Parameters.Count - 1, Type = type, Value = value
            });

            self.Inner.Operations.Add(sql);
            return(self.Inner);
        }
Beispiel #3
0
 public static LolitaSetting <TEntity> Divide <TEntity>(this LolitaValuing <TEntity, int> self, object value)
     where TEntity : class, new()
 => self.valuing("Divide", value);
Beispiel #4
0
 public static LolitaSetting <TEntity> Multiply <TEntity>(this LolitaValuing <TEntity, int> self, object value)
     where TEntity : class, new()
 => self.valuing("Multiply", value);
Beispiel #5
0
 public static LolitaSetting <TEntity> Subtract <TEntity>(this LolitaValuing <TEntity, int> self, object value)
     where TEntity : class, new()
 => self.valuing("Subtract", value);
Beispiel #6
0
 public static LolitaSetting <TEntity> Mod <TEntity>(this LolitaValuing <TEntity, long> self, object value)
     where TEntity : class, new()
 => self.valuing("Mod", value);
Beispiel #7
0
 public static LolitaSetting <TEntity> WithValue <TEntity, TProperty>(this LolitaValuing <TEntity, TProperty> self, object value)
     where TEntity : class, new()
 => self.valuing("WithValue", value);
Beispiel #8
0
 public static LolitaSetting <TEntity> WithSQL <TEntity, TProperty>(this LolitaValuing <TEntity, TProperty> self, Func <string, string> sql, params object[] parameters)
     where TEntity : class, new()
 {
     return(self.WithSQL((x, y) => sql(x)));
 }
Beispiel #9
0
 public static LolitaSetting <TEntity> Prepend <TEntity>(this LolitaValuing <TEntity, string> self, string value)
     where TEntity : class, new()
 => self.valuing("Prepend", value);
Beispiel #10
0
 public static LolitaSetting <TEntity> AddYears <TEntity>(this LolitaValuing <TEntity, DateTime> self, int value)
     where TEntity : class, new()
 => self.valuing("AddYears", value);
Beispiel #11
0
 => self.valuing("Mod", value); public static LolitaSetting <TEntity> Plus <TEntity>(this LolitaValuing <TEntity, float> self, object value)
     where TEntity : class, new()
 => self.valuing("Plus", value);
Beispiel #12
0
 public static LolitaSetting <TEntity> Mod <TEntity>(this LolitaValuing <TEntity, ushort> self, object value)
     where TEntity : class, new()
 => self.valuing("Mod", value); public static LolitaSetting <TEntity> Plus <TEntity>(this LolitaValuing <TEntity, double> self, object value)
Beispiel #13
0
 public static LolitaSetting <TEntity> Plus <TEntity>(this LolitaValuing <TEntity, int> self, object value)
     where TEntity : class
 => self.valuing("Plus", value);
Beispiel #14
0
 public static LolitaSetting <TEntity> AddMonths <TEntity>(this LolitaValuing <TEntity, DateTime> self, int value)
     where TEntity : class
 => self.valuing("AddMonths", value);
Beispiel #15
0
 public static LolitaSetting <TEntity> Append <TEntity>(this LolitaValuing <TEntity, string> self, string value)
     where TEntity : class
 => self.valuing("Append", value);