ObjectContext instance has been disposed when using BrightIdeasSoftware's ObjectListView - entity-framework-6

Trying to add a filter for the list. I have a textbox and an event that does this when the textbox text changes:
this.objectListView1.ModelFilter = TextMatchFilter.Contains(this.objectListView1, filterString.Text);
When I key in a character into the textbox I am getting the following error:
System.ObjectDisposedException: 'The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.'
I am using Entity Framework to get the data for the list view. I fill my data when the form with the listview loads using a method for that.
What is causing the error? How do I correct this?

Related

How to find the distinct error messages of model state validation failure in asp.net mvc

I want to filter the Error Messages that gets populated as part of data annotation modelstate validation failure. As in if an array of objects comes as a part of class, and the validation fails for more than one object, I do not want the same message to be added again and again. Instead, I want to find the distinct error messages
string ValidationFailure= string.Join(";", actionContext.ModelState.Values.Distinct().Select(x.ErrorMessage));
But not able to get the required output.
It looks like your attempt is close, but you’re using Distinct on something that’s already unique (Values). Instead, try the following variation:
string ValidationFailure = string.Join(";", actionContext.ModelState.Values.Select(x => x.ErrorMessage).Distinct());
This ensures that you get a distinct list of ErrorMessages.

ASP.Net Web API 2 Serialized JSON Error: "Self Referencing Loop"

Web API Controller calls a stored procedure in an Entity Framework Database-First Model.
The stored procedure inserts an entry into my SQL Server Database and then returns that newly created entry.
The Function Import of the stored procedure is set to return a Complex Type, which is a custom created TagDTO(This DTO is created within TasksModel.tt)
However, I continue to get the error "Self Referencing Loop Detected" when this API method is called.
What am I missing from the below? The stored procedure does insert the data correctly.
TagDTO class:
API Controller code:
Make sure that you remove the object from your db context before returning it. I believe this can be done by adding the following Evict method to your db context. This will make it so that it only serializes the immediate values for that object, it will not attempt to serialize Navigation Properties.
// this goes inside of your Context Object, parent class may already implement it
public void Evict(object entity)
{
Entry(entity).State = EntityState.Detached;
}
then use it like this:
dbContext.Evict(entityFrameworkObject);

How to fetch value of Dataslots in custom Jsp in Savvion BPM?

I am using Progress Savvion BPM Studio 8.0.
I want to use value of "Dataslot" (variable) in custom jsp page with Scriptlet.
I am getting value of some "Dataslot" from previous activity and now I want to perform some action on that "Dataslot" and display it in table. But I don't know how to get/use value of "Dataslot" inside scriptlet.
I should use request.getParameter() or jst.getDataSlotValue().
I tried both of them but I am not getting any error or output.
You need to get it from bean.getProp(String,Object,Boolean) based on the type of the dataslot in the JSP. You also need to add the dataslot as input to the BizSolo or Custom JSP you have added in the bizlogic process.
Also you need to define bean with com.savvion.BizSolo.beans.Bean and with scope as Session.

JSF component created in encodeBegin not visible in decode [duplicate]

This question already exists:
Closed 10 years ago.
Possible Duplicate:
Primefaces commandButton in custom component action listener not called
I have created custom component which extends UIComponentBase. I am creating
some component in encodeBegin (CommandButton from Primefaces), but when
is decode triggered by user clicking button when I look for button it is not
present in UIViewRoot and not in this.getChildren().
It seems that it is a new instance of component invoked when decode is trigered and components are not present.
What is wrong?
Some code is in:
code
If you want I can send whole code.
I found that this technique is used in PrimeFaces and other software, but can you explain why values retrieved from getStateHelper().eval("someKey"); are always null in decode?
Probably problem on my site, but I can not solve it?
This is link to thread I started:
problem description in more details
It seems that it is a new instance of component invoked when decode is trigered and components are not present.
That's correct. Component instances are not stored in the view state. Instead, the component's state is stored in the view state. The component's state can be managed by the helper class StateHelper which is available by UIComponent#getStateHelper().
So, during encode do:
// ...
getStateHelper().put("someKey", someKey);
And during decode do:
SomeKey someKey = (SomeKey) getStateHelper().eval("someKey");
// ...
See also:
How to save state when extending UIComponentBase
JSF composite component - weird behavior when trying to save state
JSF 2 Custom components having Expression Language for attribute value don't trigger the attribute setter

Not able to set WorkItem State using TFS API?

I am trying to set State property value of Test Case Work item. I am creating using TFS API and C# code.
It throws an error while I save the test case using Save() method. I have called the Validate() method of a work item and the ArrayList shows the value I am trying to assign is an invalid state.
testCase.State = TestPointState.Ready.ToString();
ArrayList result = testCase.WorkItem.Validate();
if (!testCase.WorkItem.IsValid())
{
//this block executes
}
When I manually opened the MTM to see what are the different STATE values for existing work items, then I found READY and DESIGN. That's why I tried t assign TestPointState.Ready enum. I tried assiging READY string directly in that statement, but still the same exception whlie saving the test case.
Any idea on how to fix this issue ?
It is possible that when setting the state another field has then an invalid input. e.g.: when you change from Ready to Design it might require that you select who the AssignTo person is and so you'll need to populate these fields as well. You can use the Validate method to get a list of invalid fields after you set the state like below.
ArrayList invalidFields = newWI.Validate();

Resources