DI broken in .NET6? - .net-6.0

I'm doing something completely normal - registering Insight.Database autointerfaces in WebApi DI.
Here's the code -
var dataString = builder.Configuration.GetConnectionString("DefaultConnection");
SqlInsightDbProvider.RegisterProvider();
var connection = new SqlConnection(dataString);
builder.Services.AddTransient(thing => connection.AsParallel<IUserData>());
builder.Services.AddTransient(thing => connection.AsParallel<IRoleData>());
And I'm getting this bizarre error at the point where the injected interfaces are used in a controller.
And there's no documentation on it. Nothing has changed from other projects where it works perfectly fine. It's just... broken.
Any help would be hugely appreciated
Editing to add stack trace

Inevitably, the problem turned out to be between keyboard and chair.
I was attempting to structure my returns from the database using Insight's [Recordset] attributes like so...
[Recordset(1, typeof(UserClaim), GroupBy = nameof(UserClaim.UserId), Into=nameof(ApplicationUser.UserClaims))]
except I'd forgotten to specify the relationship type. So amending this on all applicable calls to
[Recordset(1, typeof(UserClaim), IsChild = true, GroupBy = nameof(UserClaim.UserId), Into=nameof(ApplicationUser.UserClaims))]
sorted it all out.

Related

How can I change the column name of an existing Class in the Parse.com Web Browser interface?

I couldn't find a way to change a column name, for a column I just created, either the browser interface or via an API call. It looks like all object-related API calls manipulate instances, not the class definition itself?
Anyone know if this is possible, without having to delete and re-create the column?
This is how I did it in python:
import json,httplib,urllib
connection = httplib.HTTPSConnection('api.parse.com', 443)
params = urllib.urlencode({"limit":1000})
connection.connect()
connection.request('GET', '/1/classes/Object?%s' % params, '', {
"X-Parse-Application-Id": "yourID",
"X-Parse-REST-API-Key": "yourKey"
})
result = json.loads(connection.getresponse().read())
objects = result['results']
for object in objects:
connection = httplib.HTTPSConnection('api.parse.com', 443)
connection.connect()
objectId = object['objectId']
objectData = object['data']
connection.request('PUT', ('/1/classes/Object/%s' % objectId), json.dumps({
"clonedData": objectData
}), {
"X-Parse-Application-Id": "yourID",
"X-Parse-REST-API-Key": "yourKEY",
"Content-Type": "application/json"
})
This is not optimized - you can batch 50 of the processes together at once, but since I'm just running it once I didn't do that. Also since there is a 1000 query limit from parse, you will need to do run the load multiple times with a skip parameter like
params = urllib.urlencode({"limit":1000, "skip":1000})
From this Parse forum answer : https://www.parse.com/questions/how-can-i-rename-a-column
Columns cannot be renamed. This is to avoid breaking an existing app.
If your app is still under development, you can just query for all the
objects in your class and copy the value of the old column to the new
column. The REST API is very useful for this. You may them drop the
old column in the Data Browser
Hope it helps
Yes, it's not a feature provided by Parse (yet). But there are some third party API management tools that you can use to rename the fields in the response. One free tool is called apibond.com
It's a work around, but I hope it helps

Insert row DataWindow but dropdownlist doesn't show

I beg your solution to my script in PowerBuilder. I think it's fine but doesn't work properly.
Here's the script:
long ll_newrow
ll_newrow = dw_2.InsertRow(0)
dw_2.object.rectype[ll_newrow] = 'I'
dw_2.object.procyear[ll_newrow] = off_procyear
dw_2.object.procmth[ll_newrow] = off_procmth
dw_2.object.batchno[ll_newrow] = off_batchno
dw_2.object.pibseqno[ll_newrow] = pib_max
//dw_2.object.modifydate[ll_newrow] = id_modifydate
//dw_2.object.modifier[ll_newrow] = 'I-' + TRIM(is_modifier)
dw_2.ScrollToRow(ll_newrow)
dw_2.setcolumn("pibseqno")
dw_2.SetFocus()
Data in dropdown list that I've made in DataWindow doesn't show in run time, but it's fine in development.
You'll probably want to do a GetChild on the column in question, SetTransObject() on the DataWindowChild, then Retrieve() on the DataWindowChild. There are many ways to populate a DropDownDataWindow (I'm assuming it's a DDDW that you're asking about), but this is the most common, other than maybe AutoRetrieve which AFAIK isn't applicable when you only do an InsertRow().
Good luck,
Terry.

Selecting single items from MVC enumerable models

when using a MVC 3 collection that uses IEnumerable, is there a way to make small queries work to find single values? I've been experimenting with little success.
I have a collection of settings that have descriptions and settings. The problem is exposing one of them, as each is unique. I've tried something like this:
var appl = _service.GetSettings(id, app); //Call to service layer & repository
appl.Select(a => a.setting_value.Where(a.setting_name.StartsWith("Login")));
With little success (unless I'm missing something). Is it possible to select one item from an enumerable collection and either pass it to a ViewBag or ViewData object? What I would like to do is something like the following:
var appl = _service.GetSettings(id, app); //Call to service layer & repository
ViewBag.Login = appl.Select(a => a.setting_value.Where(a.setting_name.StartsWith("Login")));
And pass this to the view, since I have a view that now combines a collection with single values.
The following seems to work within the view:
Application Name #Html.TextBox("application_name", #Model.FirstOrDefault().app_name)
But I'm not sure if this violates separation of concerns. Am I on the wrong path here? Thank you!
EDIT: Here is what I needed. The answers below got me very very close +1 +1
ViewBag.Login = appl.Where(a => a.setting_name.StartsWith("Login")).FirstOrDefault().setting_value
ViewBag.Login = appl.Select(a => a.setting_value.Where(a.setting_name.StartsWith("Login"))).FirstOrDefault();
This will select the first object that matches your criteria and return a single result or null
var appl = _service.GetSettings(id, app);
ViewBag.Login = appl
.Where(a => a.setting_name.StartsWith("Login"))
.FirstOrDefault();

How to manually load an entity as well as a related entity

I have two entity objects one that holds billing address information(TBLADDRESS) and one that holds my account addresses(TBLMYACCOUNTADDRESS).
At a point in my project i need to load the TBLADDRESS object with the corresponding values from TBLMYACCOUNTADDRESS. Both of which have a relation to LKSTATE.
My problem is i cannot populate this related entity manually. Maybe it's not possible?
Here is my script so far, hopefully it will help you better understand exactly what i am trying to accomplish:
TBLADDRESS tblBilling = new TBLADDRESS();
TBLMYACCOUNTADDRESS myAccountDefaultAddress = new TBLMYACCOUNTADDRESS();
myAccountDefaultAddress = myAccountAddress.FindAll(delegate(TBLMYACCOUNTADDRESS i) { return i.IS_DEFAULT == true; }).ToList().SingleOrDefault();
tblBilling = new TBLADDRESS();
tblBilling.FIRST_NAME = myAccountDefaultAddress.FIRST_NAME;
tblBilling.LAST_NAME = myAccountDefaultAddress.LAST_NAME;
tblBilling.COMPANY = myAccountDefaultAddress.COMPANY;
tblBilling.ADDRESS_1 = myAccountDefaultAddress.ADDRESS_1;
tblBilling.ADDRESS_2 = myAccountDefaultAddress.ADDRESS_2;
tblBilling.CITY = myAccountDefaultAddress.CITY;
tblBilling.LKSTATE.STATE_ID = myAccountDefaultAddress.LKSTATE.STATE_ID;
tblBilling.POSTAL_CODE = myAccountDefaultAddress.POSTAL_CODE;
tblBilling.PHONE = myAccountDefaultAddress.PHONE;
Question is how would i go about populating the tblBilling.LKSTATE.STATE_ID manually. Currently i get an object reference not set to an instance of an object error message, but something tells me there's more to it than that.
Thanks in Advance,
Billy
Figured it out.
All i need was the instance of the object created before assigning to it.
tblBilling.LKSTATE = new LKSTATE();
Initially i wasn't sure just how to create the instance. Pretty straightforward.

Error when I try to read/update the .Body of a Task via EWS Managed API - "You must load or assign this property before you can read its value."

I am using the Exchange Web Services Managed API to work with Tasks (Exchange 2007 SP1). I can create them fine. However, when I try to do updates, it works for all of the fields except for the .Body field. Whenever I try to access (read/update) that field, it gives the following error:
"You must load or assign this property before you can read its value."
The code I am using looks like this:
//impersonate the person whose tasks you want to read
Me.Impersonate(userName); //home-made function to handle impersonation
//build the search filter
Exchange.SearchFilter.SearchFilterCollection filter = New Exchange.SearchFilter.SearchFilterCollection();
filter.Add(New Exchange.SearchFilter.IsEqualTo(Exchange.TaskSchema.Categories, "Sales"));
//do the search
EWS.Task exTask = esb.FindItems(Exchange.WellKnownFolderName.Tasks, filter, New Exchange.ItemView(Integer.MaxValue));
exTask.Subject = txtSubject.Text; //this works fine
exTask.Body = txtBody.Text; //This one gives the error implying that the object isn't loaded
The strange thing is that, inspecting the property bag shows that the object contains 33 properties, but {Body} is not one of them. That property seems to be inherited from the base class .Item, or something.
So, do I need to re-load the object as type Item? Or reload it via .Bind or something? Keep in mind that I need to do this with thousands of items, so efficiency does matter to me.
Calling the Load method solved my problem :)
foreach (Item item in findResults.Items)
{
item.Load();
string subject = item.Subject;
string mailMessage = item.Body;
}
I had the same problem when using the EWS. My Code is requesting the events(Appointments) from the
Outlook calendar, at the end I couldn't reach to the body of the Event itself.
The missing point in my situation was the following "forgive me if there is any typo errors":
After gathering the Appointments, which are also derived from EWS Item Class, I did the following:
1- Create a List with the type Item:
List<Item> items = new List<Item>();
2- Added all appointments to items list:
if(oAppointmentList.Items.Count > 0) // Prevent the exception
{
foreach( Appointment app in oAppointmentList)
{
items.Add(app);
}
}
3- Used the exchanged service "I have already created and used":
oExchangeService.LoadPropertiesForItems(items, PropertySet.FirstClassProperties);
now if you try to use app.Body.Text, it will return it successfully.
Enjoy Coding and Best Luck
I forgot to mention the resource:
http://social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/thread/ce1e0527-e2db-490d-817e-83f586fb1b44
He mentioned the use of Linq to save the intermediate step, it will help you avoid using the List items and save some memory!
RockmanX
You can load properties using a custom property set. Some properties are Extended properties instead of FirstClassProperties.
Little example:
_customPropertySet = new PropertySet(BasePropertySet.FirstClassProperties, AppointmentSchema.MyResponseType, AppointmentSchema.IsMeeting, AppointmentSchema.ICalUid);
_customPropertySet.RequestedBodyType = BodyType.Text;
appointment.Load(_customPropertySet);

Resources