Esempio n. 1
0
        private void LoadMembers(SqlCircleBuilder builder, string circleId, SqlConnection connection)
        {
            using (var command = connection.CreateCommand())
            {
                command.CommandText = "SELECT * FROM userCircles WHERE circleId = @id";
                command.Parameters.Add(new SqlParameter("@id", circleId));

                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        builder.ReadAppendMember(reader);
                    }
                }
            }
        }
Esempio n. 2
0
        public List <Circle> FindAll()
        {
            using (var command = provider.Connection.CreateCommand())
            {
                command.CommandText = @"
 SELECT *
 FROM circles
 LEFT OUTER JOIN userCircles
   ON circles.id = userCircles.circleId
";

                using (var reader = command.ExecuteReader())
                {
                    if (!reader.Read())
                    {
                        return(new List <Circle>());
                    }

                    var builder = new SqlCircleBuilder(reader);

                    var circles = new List <Circle>();
                    while (reader.Read())
                    {
                        var circleId = (string)reader["id"];
                        if (circleId != builder.CircleId)
                        {
                            var circle = builder.Build();
                            circles.Add(circle);

                            builder.Clear();
                            builder.ReadCircle(reader);
                        }

                        builder.ReadAppendMember(reader);
                    }

                    var lastCircle = builder.Build();
                    circles.Add(lastCircle);

                    return(circles);
                }
            }
        }