Int64 / Long / Bigint Property is not supported in EPiServer 8

Yes, you read it right. You can’t have a model property of type Int64 / long.

I came across an issue where in I have a model that requires to store an Id (from the database) as one of it’s properties. It so happens that most tables we have at work go by an Id of type Bigint (SQL Server).

So I had to create something like:

 public class MyModel {  
[Editable(false)]
[BackingType(typeof(PropertyNumber))]
public virtual long SomeObjectId { get; set;}
// and some other properties below...
}

However, when I run the app, I get the following error:

Type ‘System.Int64’ could not be mapped to a PropertyDefinitionType

Yes, PropertyNumber only supports Int32, etc.

So I fixed this by changing the data type to string so it stores the Int64 as string, but parse it back when I need it as Int64.

 public class MyModel {  
[Editable(false)]
[BackingType(typeof(
PropertyString))]
public virtual string SomeObjectId { get; set;}
// and some other properties below...
}

Notice that I also updated the backing type.

I’m not sure if this is the best way of playing with Int64’s, but it solved my problem!

PS. Looks like this has been the case ever since

Leave a Reply

Your email address will not be published. Required fields are marked *