# CategoryId is null

**URL:** <https://forum.litium.com/t/categoryid-is-null/934>\
**Category:** Questions\
**Tags:** litium-7\
**Created:** [June 19, 2019, 10:12am UTC](https://forum.litium.com/t/categoryid-is-null/934 "2019-06-19T10:12:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![aram](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/aram/32/19_2.png) [@aram](https://forum.litium.com/u/aram)\
**Post date:** [June 19, 2019, 10:12am UTC](https://forum.litium.com/t/categoryid-is-null/934/1 "2019-06-19T10:12:49Z")

</div>

Hi,

I am trying to get a category through code. I have tried 2 different ways but i noticed that CategoryId in the databse is null which means I can not get the category by searching for the categoryId. is this normal? Shouldn’t categories have an Id?

Have tried these:

```auto
var rootCategories = _categoryService.GetChildCategories(Guid.Empty, Assortment.SystemId);
var rootCategory = rootCategories?.FirstOrDefault(c => c.Id?.Equals("Däck", 
                                          StringComparison.InvariantCultureIgnoreCase) ?? false);

```

and

```auto
_categoryService.Get("Däck")

```

Litium version: 7.2.0

---

<div class="post-metadata">

**Author:** ![Ericsj11](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/ericsj11/32/899_2.png) [@Ericsj11](https://forum.litium.com/u/Ericsj11)\
**Post date:** [June 19, 2019, 11:07am UTC](https://forum.litium.com/t/categoryid-is-null/934/2 "2019-06-19T11:07:43Z")

</div>

> [@No Id on category when creating it from BO](https://forum.litium.com/t/no-id-on-category-when-creating-it-from-bo/730/2):
>
> Yes, the Id is null by design, since it is used for integration purpose.

---

<div class="post-metadata">

**Author:** ![aram](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/aram/32/19_2.png) [@aram](https://forum.litium.com/u/aram)\
**Post date:** [June 19, 2019, 11:20am UTC](https://forum.litium.com/t/categoryid-is-null/934/3 "2019-06-19T11:20:40Z")

</div>

okej, have you solved this somehow? Any work around. In my case all categories will be created from BO. 😕

---

<div class="post-metadata">

**Author:** ![Ericsj11](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/ericsj11/32/899_2.png) [@Ericsj11](https://forum.litium.com/u/Ericsj11)\
**Post date:** [June 19, 2019, 11:52am UTC](https://forum.litium.com/t/categoryid-is-null/934/4 "2019-06-19T11:52:15Z")

</div>

In my case i could hard code the SystemId because it’s only 1 category and we are using it in a special way.

---

<div class="post-metadata">

**Author:** ![aram](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/aram/32/19_2.png) [@aram](https://forum.litium.com/u/aram)\
**Post date:** [June 19, 2019, 12:01pm UTC](https://forum.litium.com/t/categoryid-is-null/934/5 "2019-06-19T12:01:08Z")

</div>

okey, thanks for your reply.

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [June 20, 2019, 7:49am UTC](https://forum.litium.com/t/categoryid-is-null/934/6 "2019-06-20T07:49:21Z")

</div>

You can add the readable Id yourself to the DB through integration or by script in order to get this to work as you would like to.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/12eddac3b8b661de1db86af10ac8151b571e6fb9.png) [@system](https://forum.litium.com/u/system)\
**Post date:** [July 18, 2019, 7:56am UTC](https://forum.litium.com/t/categoryid-is-null/934/7 "2019-07-18T07:56:48Z")

</div>

Closed on July 18, 2019, 7:56am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
