public string GetSelectString <T>(string collectionName, Expression <Func <T, Boolean> > filter, string orderBy, bool onlyOne = false) { ExpressionTranslator expressionTranslator = new ExpressionTranslator(); DbCollection collection = _collections[collectionName]; StringBuilder str = new StringBuilder(); str.Append(" select "); if (onlyOne) { str.Append(" Top 1 "); } str.Append(collection.GetFields()); str.Append(" from ["); str.Append(collectionName); str.Append("] "); string sqlWhere = filter == null ? "" : expressionTranslator.Translate <T>(filter); str.Append(string.IsNullOrEmpty(sqlWhere) ? " " : " where " + sqlWhere); if (!string.IsNullOrEmpty(orderBy)) { str.Append(orderBy); } return(str.ToString()); }
public string GetInsertString(string collectionName, Object entity) { DbCollection collection = _collections[collectionName]; StringBuilder str = new StringBuilder(); str.Append(" insert into ["); str.Append(collectionName); str.Append("] ("); str.Append(collection.GetFields()); str.Append(") values ("); str.Append(collection.GetFieldValuesForInsert(entity)); str.Append(") "); return(str.ToString()); }