Hello,
You can do that in the config.
The proper way according to documentation [1] would be,
I believe, the following code:
<cacheConfiguration>
...
<queryEntities>
<queryEntity keyType='System.Int32'
valueType='Some.Assembly.Qualified.Path.OrderEntity, Foo.Bar'>
<fields>
<queryField name='OrderId' fieldType='System.Int32' />
<queryField name='OrderName' fieldType='System.String' />
</fields>
<indexes>
<queryIndex>
<fields>
<queryIndexField name='OrderId' />
</fields>
</queryIndex>
</indexes>
</queryEntity>
</queryEntities>
</cacheConfiguration>
P.S. I'm not quite familiar with .NET so excuse me for possible
inaccuracies.
[1] -
https://apacheignite-net.readme.io/docs/sql-queries#section-configuring-sql-indexes-using-queryentity
Best Regards,
Igor
On Wed, Mar 8, 2017 at 9:04 AM, mrinalkamboj <[email protected]>
wrote:
> This is how I declare an entity in C#, which needs to be persisted in the
> Cache:
>
> *
> [Serializable]
> public class OrderEntity
> {
> [QuerySqlField(IsIndexed = true)]
> public int OrderId { get; set; }
>
> [QuerySqlField]
> public string OrderName { get; set; }
> }
> *
>
> The same entity, I want to propagate further in the application, for
> processing once its fetched from the Cache, but the challenge is attribute
> *[QuerySqlField]* needs Apache ignite reference, which then needs to
> propagate to higher layers, which is undesirable, so only options are:
>
> 1. Either I can define these details in the config file, since they are
> mandatory for Sql querying the entity.
>
> Not sure if the same can be defined under *cacheConfiguration -
> queryEntities* as follows
>
> *
> <cacheConfiguration>
> <cacheConfiguration name="OrderCache" cacheMode="Replicated"
> startSize="104857600">
> <cacheStoreFactory type="OrderCacheStoreFactory,ApacheIgnite"/>
> <queryEntities>
> <queryEntity keyType="System.Int32"
> valueType="OrderEntity,ApacheIgnite" keyTypeName="OrderId"
> valueTypeName="OrderEntity"/>
> <queryEntity keyType="System.String"
> valueType="OrderEntity,ApacheIgnite" keyTypeName="OrderName"
> valueTypeName="OrderEntity"/>
> </queryEntities>
> </cacheConfiguration>
> </cacheConfiguration>
> *
>
> 2. Define a separate business entity, do the explicit mapping post fetching
> the Cache entity, which is the last option due to lot of extra work
>
>
>
>
>
> --
> View this message in context: http://apache-ignite-users.
> 70518.x6.nabble.com/Define-QuerySqlField-in-the-config-
> file-instead-of-C-code-tp11067.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>