I have an ObservableColection totalsCol and want to retrieve an object whose id matches the specified id. I coded as :
IEnumerable<Totals> ie = totalsCol.Where(a => a.IdCTS == ct1.TOR_Id);
if (ie.Count() > 1)
{
// Update the TotalCts of Totals object
ie.ElementAt(0).TotalCTS = ct1.TotalCts;
CalculateTotalsPercent();
}
I get ie.count as null. Whereas it has 3 records. And on debugging, I can see that under Source of base.
Where am I wrong here ? I beleive the way am updating the the value with ie.ElementAt will reflect changes in totalsCol observableCollection.
Kindly help me out.
I implemented :
totalsCol.First(a => a.IdCTS == ct1.TOR_Id);
and solved the issue.
Related
I have the following query:
SELECT * FROM c
WHERE c.DateTime >= "2017-03-20T10:07:17.9894476+01:00" AND c.DateTime <= "2017-03-22T10:07:17.9904464+01:00"
ORDER BY c.DateTime DESC
So as you can see I have a WHERE condition for a property with the type DateTimeand I want to sort my result by the same one.
The query ends with the following error:
Order-by item requires a range index to be defined on the corresponding index path.
I have absolutely no idea what this error message is about :(
Has anybody any idea?
You can also do one thing that don't require indexing explicitly. Azure documentBD is providing indexing on numbers field by default so you can store the date in long format. Because you are already converting date to string, you can also convert date to long an store, then you can implement range query.
I think I found a possible solution, thanks for pointing out the issue with the index.
As stated in the following article https://learn.microsoft.com/en-us/azure/documentdb/documentdb-working-with-dates#indexing-datetimes-for-range-queries I changed the index for the datatype string to RangeIndex, to allow range queries:
DocumentCollection collection = new DocumentCollection { Id = "orders" };
collection.IndexingPolicy = new IndexingPolicy(new RangeIndex(DataType.String) { Precision = -1 });
await client.CreateDocumentCollectionAsync("/dbs/orderdb", collection);
And it seems to work! If there are any undesired side effects I will let you know.
I seem to be having a problem with assigning values to fields of a content item with a custom content part and the values not persisting.
I have to create the content item (OrchardServices.ContentManager.Create) first before calling the following code which modifies a field value:
var fields = contentItem.As<MyPart>().Fields;
var imageField = fields.FirstOrDefault(o => o.Name.Equals("Image"));
if (imageField != null)
{
((MediaLibraryPickerField)imageField).Ids = new int[] { imageId };
}
The above code works perfectly when against an item that already exists, but the imageId value is lost if this is done before creating it.
Please note, this is not exclusive to MediaLibraryPickerFields.
I noticed that other people have reported this aswell:
https://orchard.codeplex.com/workitem/18412
Is it simply the case that an item must be created prior to amending it's value field?
This would be a shame, as I'm assigning this fields as part of a large import process and would inhibit performance to create it and then modify the item only to update it again.
As the comments on this issue explain, you do need to call Create. I'm not sure I understand why you think that is an issue however.
I meet a problem with count request of neo4j with nodejs.
Here my problem :
When I insert a data, it will present like this:
start a = node(0)
create unique a-[:HAS_ID]->(b{id:'xx'})
create unique b-[:HAS_INFO]->(c{info:'xx'})
return a,b,c;
because it's unique node, so that it will not insert a new node if there are a same node exist. But, I wanna count how many request to call this query.
Ex :
request: -domain/id01/info
--return a node[0], b node[1] and c node[2]
add another data:
request: -domain/id02/info
-- return : a node[0], b node[3], c node[4]
call it again :
request: -domain/id01/info
--return a node[0], b node[1] and c node[2] //but here is any attribute or properties count to 2.
I've read any solution about strength. It told me create an properties of relationship as example :
[:HAS_INFO{strength:num}]
and let it increase but I still don't get it.
Anyone please give me solution and tell me how to do it.
Thank you.
more info : Representing (and incrementing) relationship strength in Neo4j
You can use the CASE statement, see http://gist.neo4j.org/?6052414 for an example. Feel free to for the underlying gist and improve it!
MATCH path=(a)-[rel:HAS_INFO]->(b)
WHERE a.name?='A' AND b.name?='Info'
SET rel.weight = (
CASE
WHEN not(has(rel.weight))
THEN 0
ELSE rel.weight + 1
END)
RETURN path, rel.weight;
I have a custom entity named eld_timereg. This entity has an attribute named eld_name (which is the primary field). Records are created in a generic handler (after pushing a button in the ribbon). I'm using late binding.
var myService = ...;
var t = new Entity( "eld_timereg" );
t["field1"] = "abc";
.
.
.
t["eld_name"] = GenerateAnUniqueStringCode("ZXC");
// returns something like ZXC-16398-T1VC
return myService.Create(t);
The record is created without any error. Checking the entity in SSMS, the value is blank although it is a required field.
What is happening here?
Found the problem. You put me on the right track James. Thank you for that. The eld_name attribute was overwritten in the plug-in (I forgot). Here it should be filled with some information. This was going wrong and always returned a null.
I am updating some list items through code.
Here is an example of what I am trying to do
SPListItem item = GetListItem();
item["Field1"] = GetField1ValueFromControl();
item["Field2"] = GetField2ValueFromControl();
item.Update();
if (!item.MissingRequiredFields)
{
SuccessRedirect();
}
else
{
Error("Fields missing");
}
In this example the Field2 is set as a required field, so if the user doesn't enter a value then it would show an error and they could enter a value.
The problem I seem to be having is that after the first error, even after they have entered a value for the required field the MissingRequiredFields property is still returning true after they have resubmitted the page
Any one got any ideas?
I worked this out.
You need to use the Page.IsValidated method to check the controls.
The item will always update whether the required fields are entered or not.
The MissingRequiredFields is not valid until after the update.