Пример #1
0
        //public KanjiStrokes GetKanjiStrokes(long id)
        //{
        //    KanjiStrokes result = null;

        //    DaoConnection connection = null;
        //    try
        //    {
        //        // Create and open synchronously the primary Kanji connection.
        //        connection = DaoConnection.Open(DaoConnectionEnum.KanjiDatabase);

        //        // FILTERS COMPUTED.
        //        // Execute the final request.
        //        IEnumerable<NameValueCollection> results = connection.Query(
        //            "SELECT * "
        //            + "FROM " + SqlHelper.Table_KanjiStrokes + " ks "
        //            + "WHERE ks." + SqlHelper.Field_KanjiStrokes_Id + "=@ks;",
        //        new DaoParameter("@ks", id));

        //        if (results.Any())
        //        {
        //            KanjiStrokesBuilder builder = new KanjiStrokesBuilder();
        //            result = builder.BuildEntity(results.First(), null);
        //        }
        //    }
        //    finally
        //    {
        //        if (connection != null)
        //        {
        //            connection.Dispose();
        //        }
        //    }

        //    return result;
        //}

        public KanjiStrokes GetKanjiStrokes(long id)
        {
            KanjiStrokes result = new KanjiStrokes();

            result.ID        = id;
            result.FramesSvg = new byte[0];

            DaoConnection    connection = null;
            SQLiteDataReader reader     = null;

            try
            {
                // Create and open synchronously the primary Kanji connection.
                connection = DaoConnection.Open(DaoConnectionEnum.KanjiDatabase);

                reader = connection.QueryDataReader(
                    string.Format("SELECT {0} FROM {1} WHERE {2}=@id;",
                                  SqlHelper.Field_KanjiStrokes_FramesSvg,
                                  SqlHelper.Table_KanjiStrokes,
                                  SqlHelper.Field_KanjiStrokes_Id),
                    new DaoParameter("@id", id));

                while (reader.Read())
                {
                    result.FramesSvg = GetBytes(reader);
                }
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                    reader.Dispose();
                }
                if (connection != null)
                {
                    connection.Dispose();
                }
            }

            return(result);
        }