private void ExtMapper(MapperExpressionInfo fillInfo, MapperExpressionInfo mappingFild1Info, MapperExpressionInfo mappingFild1Info2, MapperExpressionInfo selectInfo) { var tableName = sqlBuilder.GetTranslationTableName(fillInfo.EntityInfo.DbTableName); var whereLeft = sqlBuilder.GetTranslationColumnName(mappingFild1Info2.FieldName); var whereRight = sqlBuilder.GetTranslationColumnName(mappingFild1Info.FieldString); this.sql = this.context.Queryable <object>() .AS(tableName) .Where(string.Format(" {0}={1} ", whereLeft, whereRight)) .Select(sqlBuilder.GetTranslationColumnName(selectInfo.FieldName)).ToSql().Key; }
private void oneToOne(MapperExpressionInfo fillInfo, MapperExpressionInfo mappingFild1Info, MapperExpressionInfo mappingFild1Info2, MapperExpressionInfo selectInfo) { var pkColumn = selectInfo.EntityInfo.Columns.Where(it => it.IsPrimarykey == true).FirstOrDefault(); if (pkColumn == null) { pkColumn = selectInfo.EntityInfo.Columns.First(); } var tableName = sqlBuilder.GetTranslationTableName(fillInfo.EntityInfo.DbTableName); var whereLeft = sqlBuilder.GetTranslationColumnName(pkColumn.DbColumnName); var whereRight = sqlBuilder.GetTranslationColumnName(mappingFild1Info.FieldString); this.sql = this.context.Queryable <object>() .AS(tableName) .Where(string.Format(" {0}={1} ", whereLeft, whereRight)) .Select(sqlBuilder.GetTranslationColumnName(selectInfo.FieldName)).ToSql().Key; }
private void oneToMany(string methodName, EntityInfo mainEntity, string shortName, MapperExpressionInfo fillInfo, MapperExpressionInfo mappingFild1Info, MapperExpressionInfo mappingFild1Info2) { var pkColumn = mainEntity.Columns.FirstOrDefault(it => it.IsPrimarykey == true); if (pkColumn == null) { pkColumn = mainEntity.Columns.FirstOrDefault(); } var tableName = sqlBuilder.GetTranslationTableName(fillInfo.EntityInfo.DbTableName); var whereLeft = sqlBuilder.GetTranslationColumnName(mappingFild1Info.FieldString); var whereRight = sqlBuilder.GetTranslationColumnName(shortName + "." + pkColumn.DbColumnName); if (methodName == "Any") { this.sql = " (" + this.context.Queryable <object>() .AS(tableName) .Where(string.Format(" {0}={1} ", whereLeft, whereRight)) .Select("COUNT(1)").ToSql().Key + ")>0 "; } else { this.sql = this.context.Queryable <object>() .AS(tableName) .Where(string.Format(" {0}={1} ", whereLeft, whereRight)) .Select("COUNT(1)").ToSql().Key; } }