Blog.DAL.TagDAL.PobierzTagPosta C# (CSharp) Method

PobierzTagPosta() public method

public PobierzTagPosta ( int id ) : TagModel
id int
return Blog.Models.TagModel
        public TagModel PobierzTagPosta(int id)
        {
            using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
            {
                try
                {
                    var tagi = (from a in context.Tagis
                                where a.id_posta == id
                                select new TagModel
                                {
                                    IdPosta = a.id_posta,
                                    Desc = a.description,
                                    Keywords = a.keywords
                                }).Single();
                    //var tag = context.Tagis.Single(t => t.id_posta == id);
                    //return new TagModel
                    //      {
                    //          IdPosta = tag.id_posta,
                    //          Keywords = tag.keywords,
                    //          Desc = tag.description
                    //      };
                    return tagi;
                }
                catch (InvalidOperationException)
                {
                    return null;
                }
            }
        }