*Step-1:Model class*
---------------------------------
namespace Models.Ignite
{
   public class ENTITIESTABLEINFO : ICustomCacheStore
    {
        [QuerySqlField]
        [Key]
        public String EntityId { get; set; }
        [QuerySqlField]
        public String EntityType { get; set; }
        [QuerySqlField]
        public String EntityInfoJson { get; set; }
        [QuerySqlField]
        public String TenantName { get; set; }
        [QuerySqlField]
        public String TenantId { get; set; }
        [QuerySqlField]
        public String Fabric { get; set; }
        [QuerySqlField]
        public String EntityName { get; set; }
        [QuerySqlField]
        public double SequenceNumber { get; set; }
    }
}




*Step-2:Create Cache,table and indexes:*
--------------------------------------
using Models.Ignite.ENTITIESTABLEINFO;

//create indexes
struct QueryEntityIndexFields
{
        public string[] PrimaryKeys;
        public Type ModelType;
        //public string QueryIndexType;
}
private static readonly string[] indexFieldOfEntityId = new[] { "EntityId"
};
private static readonly QueryEntityIndexFields[] prodModels = new[] {
            //fdc models
            new QueryEntityIndexFields(){PrimaryKeys=indexFieldOfEntityId,
ModelType=  typeof(ENTITIESTABLEINFO)}
}

private async Task<List&lt;QueryEntity>>
GetQueryEntitiesBasedOnCapability(QueryEntityIndexFields[]
queryEntityIndexFieldsList)
        {
            List<QueryEntity> queryList = new List<QueryEntity>();
            foreach (var modelObject in queryEntityIndexFieldsList)
            {
                var query = new QueryEntity(typeof(string),
modelObject.ModelType)
                {
                    Indexes = new
List<QueryIndex>(modelObject.PrimaryKeys.Count() + 1)
                        {
                            new QueryIndex(true,0,modelObject.PrimaryKeys)
                        }
                };
                queryList.Add(query);
            }
            return queryList;
        }
var queryList = await
_queryEntities.CreateQueryEntitiesListAsync(capabilityName);


//Cache configuration
cacheCfg = new CacheConfiguration(cacheName)
{
        Name = cacheName,
        CacheStoreFactory = new TenantCacheStoreFactory(_logger, 
connectionString),
        KeepBinaryInStore = false,  // Cache store works with deserialized data.
        ReadThrough = true,
        WriteThrough = true,
        WriteBehindEnabled = true,
    QueryEntities = queryList,
        WriteBehindFlushThreadCount = 2,
        CacheMode = CacheMode.Partitioned,
        Backups = 0,
        DataRegionName = "IgniteDataRegion",
        EvictionPolicy = new LruEvictionPolicy
        {
                MaxSize = 100000
        }
};

Ignite.AddCacheConfiguration(cacheCfg);
// Create cache with given name, if it does not exist.
ICache<KeyModel, ICustomCacheStore> cache =
Ignite.GetOrCreateCache<KeyModel, ICustomCacheStore>(cacheCfg);

where cacheName is "C091E548-B45A-49B4-B8EC-2CB5E27C7AF6";
*
Step-3:Insert Statement:*
-------------------------
INSERT INTO
"C091E548-B45A-49B4-B8EC-2CB5E27C7AF6".ENTITIESTABLEINFO(EntityId,EntityInfoJson,EntityName,EntityType,Fabric,SequenceNumber,TenantId,TenantName)
VALUES ('0-pulsar', '{}', 'Testing Topic0 Name', 'testpulsarType',
'pulsarFabric', 0.0, 'pulsar-123-tenantid', 'pulsar-tenantName');

onces insert statement execute get before mention exception.
Anything else required,please let me know.



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Reply via email to