Hi Alexey,

Here is the code snippet,


  client config
  ===============>
  var cfg = new IgniteConfiguration
                {
                    BinaryConfiguration = new BinaryConfiguration
                    {
                        NameMapper = new BinaryBasicNameMapper {
IsSimpleName = true },
                        
                    }
                };
                                
                                

                                
                          var customersCache = ignite.GetOrCreateCache<String, 
CustomerInfo>(new
CacheConfiguration
                    {
                        Name = "customer12" + tenantName,
                        KeepBinaryInStore = false,
                        CacheStoreFactory = new
CustomerCacheStoreFactory(connectionString),
                        ReadThrough = true,
                        WriteThrough = true,
                    });
                                        
                                        
         customersCache[new Random().Next().ToString()] = new CustomerInfo { 
Name =
tenantName, Id = Id, City = city };
         
         here is the exception when putting into cache its throwing exception.
         
         
         server config:
         ==============>
         BinaryConfiguration bcnfg = new BinaryConfiguration();
        
                bcnfg.setNameMapper(new BinaryBasicNameMapper());
                
                IgniteConfiguration cfg  =  new
IgniteConfiguration().setBinaryConfiguration(bcnfg);
                Ignite ignite=Ignition.start(cfg);
                
         
         
        
         Factory implementation
         ====================================>
         In C#:(client)
         ------
          [Serializable]
    class CustomerCacheStoreFactory : IFactory<ICacheStore>
    {
        string connectionString;
        public CustomerCacheStoreFactory(string connectionString)
        {
            this.connectionString = connectionString;
        }
        public ICacheStore CreateInstance()
        {
            return new CustomerCacheStore(this.connectionString);

        }
    }
        
        In java(server)
        -------
         public class CustomerCacheStoreFactory implements
Factory<CacheStore&lt;String, CustomerInfo>>{
    
        private String connectionString;
        public CustomerCacheStoreFactory(String connectionString) {
                this.connectionString=connectionString;
        }
        public CacheStore<String, CustomerInfo> create() {
        
                return  new  CustomerCacheStore(this.connectionString);
        }

        

}

In Java and c#  Cache store where we need to write the logic to persist into
sql :
===========================================================================
public class CustomerCacheStore implements CacheStore<String, CustomerInfo>{
 load()
 write()
 ..
 ..
 
}
 
         
         Model class in c# to persist 
         ====================================
         
          class CustomerInfo
    {
        public CustomerInfo()
        {

        }
        public CustomerInfo(string id,string name,string city)
        {
            this.Id = id;

            this.Name = name;
            this.City = city;

        }
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        public string Id { get; set; }
        public string Name { get; set; }
        public string City { get; set; }
    }
        
        Model class in java 
        ==================
        
        public class CustomerInfo {
        final String id;
        final String name;
        final String city;

        public CustomerInfo(String id, String name, String city) {
                this.id= id;
                this.name = name;
                this.city = city;
        }

}





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

Reply via email to