Realm migration property said to have been remove was never added - realm

Please I have this issue with realm migration error that a property has been removed, but the issue is that I never added that property mention in the realm Object. Here is the realm Object
open class FeedbackModel(
#PrimaryKey var id : Long = -1,
var agentEmail: String? = null,
var agentName: String? = null,
var agentPhone: String? = null,
var appName: String? = null,
var comment: String? = null,
var deviceId: String? = null,
var date : String? = null,
var deviceType: String? = null,
var esaCode: String? = null,
var fepName: String? = null,
var rateValue: Int = 0
) : RealmObject()
Here is the error
: io.realm.exceptions.RealmMigrationNeededException: Migration is required due to the
following errors:
- Property 'FeedbackModel.$stable' has been removed.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3729)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4020)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2328)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8633)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Nothing like $stable property was added. Please how can I resolve this?

Related

I have Pull the value of ImagelocationID from dropdown through database using foreign key and While creating I got this error

This is my Controller
public async Task <IActionResult> SliderImage(ImageUploadViewModel imageUpload)
{
string stringFilename = UploadFile(imageUpload);
var branch = _context.BranchPages.Single(b => b.BranchId == imageUpload.ImageContentPageId);
var Sliderimage = new ImageContentModel
{
ImageOrderNo = imageUpload.ImageOrderNo,
ImageName = imageUpload.ImageName,
ImageLocation = imageUpload.ImageLocation,
RelatedLinks = imageUpload.RelatedLinks,
Image = stringFilename,
ImageContentPageId = Convert.ToInt32(branch),
};
_context.ImageContents.Add(Sliderimage);
await _context.SaveChangesAsync();
return View();
}
Error i have got
InvalidCastException: Unable to cast object of type 'H20_CafeAndPub.Models.BranchPageModel' to type 'System.IConvertible'.
System.Convert.ToInt32(object value)
H20_CafeAndPub.Controllers.HomePageController.SliderImage(ImageUploadViewModel imageUpload) in HomePageController.cs + var Sliderimage = new ImageContentModel
Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor+TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, object controller, object[] arguments)
System.Threading.Tasks.ValueTask.get_Result()
System.Runtime.CompilerServices.ValueTaskAwaiter.GetResult()
You need to change the few code like this
Change 1 :
var branch = _context.BranchPages.Where(b => b.BranchId == imageUpload.ImageContentPageId).FirstOrDefault();
Change 2 :
ImageContentPageId = Convert.ToInt32(branch.Id)

how to set value for date and amount(currency) in default constructor in corda

how to set value for date and amount(currency) field default constructor (in schema) in corda programs. I tried commenting the constructor but met with error in API.
Here is a schema with a default value for one of the fields, value:
object IOUSchemaV1 : MappedSchema(
schemaFamily = IOUSchema.javaClass,
version = 1,
mappedTypes = listOf(PersistentIOU::class.java)) {
#Entity
#Table(name = "iou_states")
class PersistentIOU(
#Column(name = "lender")
var lenderName: String,
#Column(name = "borrower")
var borrowerName: String,
#Column(name = "linear_id")
var linearId: UUID,
#Column(name = "value")
var value: Int = 93
) : PersistentState() {
// Default constructor required by hibernate.
constructor(): this("", "", UUID.randomUUID(), 0)
}
}
If you don't provide a value for this field, then the default value of 93 will be used. For example:
override fun generateMappedObject(schema: MappedSchema): PersistentState {
return when (schema) {
is IOUSchemaV1 -> IOUSchemaV1.PersistentIOU(
this.lender.name.toString(),
this.borrower.name.toString(),
this.linearId.id
)
else -> throw IllegalArgumentException("Unrecognised schema $schema")
}
}

.net Querying a Global Secondary Index in DynamoDB via DynamoDBContext

I have a dynamoDB table with a schema as follows:
var request = new CreateTableRequest
{
TableName = tableName,
KeySchema = new List<KeySchemaElement>
{
new KeySchemaElement("CompanyId", KeyType.HASH),
new KeySchemaElement("Timestamp", KeyType.RANGE)
},
AttributeDefinitions = new List<AttributeDefinition>
{
new AttributeDefinition("CompanyId", ScalarAttributeType.S),
new AttributeDefinition("Timestamp", ScalarAttributeType.N),
new AttributeDefinition("UserId", ScalarAttributeType.S)
},
GlobalSecondaryIndexes = new List<GlobalSecondaryIndex>
{
new GlobalSecondaryIndex
{
IndexName = "UserIndex",
KeySchema = new List<KeySchemaElement>
{
new KeySchemaElement("UserId", KeyType.HASH),
new KeySchemaElement("Timestamp", KeyType.RANGE)
},
Projection = new Projection {ProjectionType = "ALL"},
ProvisionedThroughput = new ProvisionedThroughput(5, 6)
}
},
ProvisionedThroughput = new ProvisionedThroughput(5, 6)
};
I can query the primary key successfully as follows:
var client = new AmazonDynamoDBClient();
using (var context = new DynamoDBContext(client))
{
var sortKeyValues = new List<object>{minTimestamp};
result = await context.QueryAsync<AuditLogEntry>(companyId, QueryOperator.GreaterThanOrEqual, sortKeyValues,
new DynamoDBOperationConfig {OverrideTableName = TableName}).GetRemainingAsync();
}
And I can query the global secondary index without any constraint on the range key as follows:
var client = new AmazonDynamoDBClient();
using (var context = new DynamoDBContext(client))
{
result = await context.QueryAsync<AuditLogEntry>(userId, new DynamoDBOperationConfig {OverrideTableName = TableName, IndexName = indexName})
.GetRemainingAsync();
}
But when I try to query the index with a range key constraint:
var client = new AmazonDynamoDBClient();
using (var context = new DynamoDBContext(client))
{
var sortKeyValues = new List<object> {minTimestamp};
result = await context.QueryAsync<AuditLogEntry>(userId, QueryOperator.GreaterThan, sortKeyValues, new DynamoDBOperationConfig {OverrideTableName = TableName, IndexName = indexName}).GetRemainingAsync();
}
I get the following error:
Exception thrown: 'System.InvalidOperationException' in AWSSDK.DynamoDBv2.dll
Additional information: Local Secondary Index range key conditions are used but no index could be inferred from model. Specified index name = UserIndex
Googling this error hasn't thrown any light on the issue. The reference to Local Secondary Index has me confused because I'm using a Global index, but I just can't see what's wrong with my code.
I've been able to get the query working by querying directly on the AmazonDynamoDBClient rather than using DynamoDBContext, but I'd really like to understand what I'm doing wrong and be able to use DynamoDBContext.
Any ideas would be appreciated.
In your model definition for AuditLogEntry you need to decorate properties that are part of the global secondary index with attributes - [DynamoDBGlobalSecondaryIndexRangeKey] and or [DynamoDBGlobalSecondaryIndexHashKey]. Example below.
public class AuditLogEntry {
// other properties ...
[DynamoDBProperty("UserId")]
[DynamoDBGlobalSecondaryIndexHashKey("UserIndex")]
public string UserId { get; set; }
}

Convert var type to GUID type

I have a var and want to change it to System.GUID .What should I do?
var requstid = Session ["y"];
want to convert type var to GUID.
If Session contains Guid, then just cast to it:
var requstid = Session ["y"] != null ? (Guid)Session ["y"] : default(Guid);
var requestId = Guid.Parse(Session["y"]);
or
var requestId = new Guid(Session["y"]);

Get Map(Types:String,Types:String) in .Net application

In AX 2009 I have class with method returning Map.
In ะก# I have null:
using (Axapta Ax = new Axapta())
{
Ax.Logon(null, null, null, null);
AxaptaObject ax = Ax.CreateAxaptaObject("SomeClass");
object obj = ax.Call("getMapData",1);
Dictionary<String, String> dict = obj as Dictionary<String, String>;
In this code dict is null. Why?
Is it possible to get complex data type from AX on .Net side?
Sorry, but a Map in X++ is not the same thing as a Dictionary in C#.
You can use a map though:
AxaptaObject map = ax.Call("getMapData",1);
Then call the map with:
String val = map.call("lookup", "key");
full code to do it (get Dictionary):
Dictionary<String,String> dict = new Dictionary<String,String>();
String key, value;
using (Axapta Ax = new Axapta())
{
Ax.Logon(null, null, null, null);
AxaptaObject someClass= Ax.CreateAxaptaObject("SomeClass");
AxaptaObject map = someClass.Call("getMapData",1) as AxaptaObject;
AxaptaObject mapIterator = Ax.CreateAxaptaObject("MapIterator", map);
while ((bool)mapIterator.Call("more"))
{
key = mapIterator.Call("key").ToString();
value = mapIterator.Call("value").ToString();
dict.Add(key,value);
mapIterator.Call("next");
}
}
return dict;

Resources