public virtual IAliasedCommandTypeDataOrder Delete(TModel model) { Clause whereCondition = Clause.New() .AddClause(IdProperty.GetValue(model), Clause.EqualStatementCallback(IdProperty.Name)); var dataOrder = Get.DeleteQuery(TableName, whereCondition); return(new AliasedCommandTypeDataOrder(dataOrder, System.Data.CommandType.Text)); }
public virtual IAliasedCommandTypeDataOrder Update(TModel model) { if (model == null) { return(new AliasedCommandTypeDataOrder()); } IEnumerable <KeyValuePair <string, object> > propertiesLinqStatement; if (model is IChangeDescriptor) { propertiesLinqStatement = ((IChangeDescriptor)model) .GetChangedProperties() .Where(p => p.PropertyName != IdProperty.Name) .Select(p => new KeyValuePair <string, object>(p.PropertyName, p.NewValue)); } else { propertiesLinqStatement = typeof(TModel) .GetProperties() .Where(p => p.Name != IdProperty.Name) .Select(p => new KeyValuePair <string, object>(p.Name, p.GetValue(model))); } KeyValuePair <string, object>[] properties = propertiesLinqStatement.ToArray(); Clause whereCondition = Clause.New() .AddClause(IdProperty.GetValue(model), Clause.EqualStatementCallback(IdProperty.Name)); var dataOrder = Get.UpdateQuery(TableName, properties, whereCondition); var updatePrependageOrder = GetUpdatePrependage(properties); string query = string.Join(";\r\n\r\n", new[] { updatePrependageOrder?.Query ?? "", dataOrder.Query }.Where(q => q.IsMeaningful())); var parameters = new List <KeyValuePair <string, object> >(dataOrder.Parameters); parameters.AddRange(updatePrependageOrder?.Parameters ?? new KeyValuePair <string, object> [0]); return(new AliasedCommandTypeDataOrder(query, System.Data.CommandType.Text, parameters)); }