ASP.NET BoilerPlate: .Net core template - app service error - aspnetboilerplate

I am in the process of moving my app code from the .Net5 MVC/JQuery ASPNETZERO template to the new .Net core 1.1 MVC/JQuery template.
So far I have copied over my first few custom entities. Created a EF migration and applied the changes to my DB.
I then started building the first app service for one of my entities. I am copying over the code from my existing MVC template that is working without any issues.
public async Task<PagedResultDto<ListValuesListDto>> GetListValues(GetListValuesInput input)
{
var query = from lv in _listvaluesRepository2.GetAll()
select new ListValuesListDto
{
Id = lv.Id,
ListName = lv.ListName,
ListText = lv.ListText
};
query = query.WhereIf(!input.Filter.IsNullOrWhiteSpace(), lv => lv.ListName.Contains(input.Filter) || lv.ListText.Contains(input.Filter));
var resultCount = await query.CountAsync();
var results = await query.OrderBy(input.Sorting).PageBy(input).ToListAsync();
return new PagedResultDto<ListValuesListDto>(resultCount, results);
}
The method above is from my MVC template. When I place this into the .Net core solution, I keep getting the following build error.
CS0411 The type arguments for method 'Enumerable.OrderBy(IEnumerable, Func)' cannot be inferred from the usage. Try specifying the type arguments explicitly
The error is pointing to the "OrderBy" on this line of code:
var results = await query.OrderBy(input.Sorting).PageBy(input).ToListAsync();
I am still very much learning the ABP template and EF. I cannot for the life of me figure out why the same code in the .Net core template does not work?
Any help that anyone can provide would be much appreciated!

I just solved my own issue. I had to add the using statement for System.Linq.Dynamic.Core
Hope it helps someone else! :-)

Related

CMS Open Payments Data Limitation

I've finally got around to getting the code needed to import web API into my SQL environment. However, when I ran the SSIS Script Component package (Script Language: Visual Studio C# 2017) I was only able to retrieve 1000 records out of of millions. A consultant mentioned that I may have to incorporate the App Token into my code in order to access additional records.
Would someone be able to confirm that this true? And if so, how should it be coded?
Here is the code prior to my "ForEach" loop code:
public override void CreateNewOutputRows()
{
//Set Webservice URL
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
string wUrl = "https://openpaymentsdata.cms.gov/resource/bqf5-h6wd.json";
string appt = "MyAppToken";
try
{
//Call getWebServiceResult to return our Article attributes
List<Payment> outPutResponse = GetWebServiceResult(wUrl);
If there's an alternative method to using the app token (like in the HTTP Connection for example) please let me know.
Figured it out...
https://openpaymentsdata.cms.gov/resource/bqf5-h6wd.json?$limit=10000&$$app_token="MyAppToken"

Problems with findEntity()

I am having a problem similar to Botframework findEntity() issue.
I have created a node.js botframework app using the azure interface. I am using the azure ide for development (to keep things simple).
The relevant code is:
// Main dialog with LUIS
var recognizer = new builder.LuisRecognizer(LuisModelUrl);
var intents = new builder.IntentDialog({ recognizers: [recognizer] })
/*
.matches('<yourIntent>')... See details at http://docs.botframework.com/builder/node/guides/understanding-natural-language/
*/
.matches('Help',(session, args) => {
var entities = args.entities;
var itype = builder.EntityRecognizer.findEntity(args.entities, 'ItemTypes');
session.send(args.entities[0]["entity"]);
session.send(args.entities[0]["type"]);
session.send('How may I assist you? ' + JSON.stringify(args));
session.send('Value of entity (didnt match) you said: \'%s\'.', itype);
})
the findEntity function returns null in itype (at least that is what I see in the session.send results.
I tried using both args.entities and args.intents.entities, no change.
When I look at the results of the args.entities[0]["entity"] and [type] I do get values. The results of the JSON.stringify are below (also showing it is finding the entity).
How may I assist you?
{"score":0.970185757,"intent":"Help","intents":[{"intent":"Help","score":0.970185757},{"intent":"Joke","score":0.0711096451},{"intent":"Greeting","score":0.0438234434},{"intent":"None","score":0.0408537947},{"intent":"Goodbye","score":0.04074517}],"entities":[{"entity":"stapler","type":"ItemTypes","
I'm assuming there is more but that it was cut off by the chat window.
I'm new to every technology involved and will take any help I can get.

Issue Retrieving a Screenshot from a database

I've got a bunch of screenshots and some screenshot meta data I'm trying to display in an ASP.NET MVC 3 web application, I'm trying to retrieve the data from my databse but I get this error:
LINQ to Entities does not recognize the method 'System.Drawing.Image
ByteArrayToImage(Byte[])' method, and this method cannot be translated
into a store expression.
Here's my code:
var screenshotData = (from screenshots in db.screenshots
where screenshots.projects_ID == projectID
select new ImageInformation
{
ID = screenshots.id,
Language = screenshots.language,
Screenshot = Utility.ByteArrayToImage(screenshots.screen_shot),
ProjectID = screenshots.projects_ID
});
foreach (ImageInformation info in screenshotData)
{
this.Add(info);
}
ImageInformation is just a simple class that contains the defintion the information stored (ID, Language, Screenshot, ProjectID).
Here's my ByteArrayToImage function:
public static Image ByteArrayToImage(byte[] byteArrayIn)
{
using (MemoryStream ms = new MemoryStream(byteArrayIn))
{
Image returnImage = Image.FromStream(ms);
return returnImage;
}
}
Can anybody tell me why I receive this error when this code runs?
Thanks.
I think it's because, with LINQ-to-Entities, the code is turned into server-side query and it can't do that in this case. I don't think you can mix client-side code like this directly with L2E.
I would suspect you will have to do the conversion from byte->image after you've retrieved the data from the database as a distinct step.
You can't do the function in a LINQ to Entities query... one option:
1) have a byte[] property on the object you are instantiating (ImageInformation) and copy the data in there along with another propery to read the image from this ImageInformation object.

CIM in an MVC3 app - how to instantiate ServiceSoap?

I'm integrating CIM into an MVC3 app. I've added a service reference using the development url and coded the following:
public long x()
{
var u = this.User.Identity as IClaimsIdentity;
var id = u.Claims.First(x => x.ClaimType == ClaimTypes.NameIdentifier);
AuthorizeNet.CustomerProfileType cust = new AuthorizeNet.CustomerProfileType();
cust.merchantCustomerId = id.Value;
AuthorizeNet.MerchantAuthenticationType merch = new AuthorizeNet.MerchantAuthenticationType();
merch.name = "8aFRk4663XMd";
merch.transactionKey = "4MS675e62fQEdUXN";
AuthorizeNet.ServiceSoap svc = new AuthorizeNet.ServiceSoap();
AuthorizeNet.CreateCustomerProfileResponseType response = svc.CreateCustomerProfile(
merch, cust, AuthorizeNet.ValidationModeEnum.none
);
return response.customerProfileId;
}
but, of course, it doesn't work because one cannot instantiate an interface like that (.ServiceSoap is an interface). The sample code makes a reference to a .Service - but that doesn't exist AFAICT.
so how is this supposed to work?
TIA - e!
p.s. I did find an old posting with precisely my problem, but alas, no solution
well... at least for now the answer seems to be: don't generate a Service Reference but a Web Reference (you can do it by clicking on the Advanced button of the Service Reference dialogue).
so eeky.

DomainProjectPicker class is obsolete in VSTS 2010?

What is the alternative for DomainProjectPicker if I want to select a server plus its projects? I am aware of a new class called TeamProjectPicker, but that doesn't help me. Anyone know how to select the server from this type of dialog?
Thanks,TS.
As far as I can figure it out it's more or less the same as the DomainProjectPicker.
Here's a code sample of how I was working with it:
if (tpp.ShowDialog() == DialogResult.OK)
{
try
{
//here you get the TfsTeamProjectCollection (the TeamFoundationServer class is also obsolete)
TfsTeamProjectCollection tfsProj = tpp.SelectedTeamProjectCollection;
//here you authenticate
tfsProj.Authenticate();
}
etc...
You can use the TeamProjectPicker class from Microsoft.TeamFoundation.Client.dll. There is a great blog post that describes how to wrangle the dialog: Using the TeamProjectPicker API in TFS 2010
Here's the code sample for selecting multiple team projects:
Application.EnableVisualStyles(); // Makes it look nicer from a console app.
//"using" pattern is recommended as the picker needs to be disposed of
using (TeamProjectPicker tpp = new TeamProjectPicker(TeamProjectPickerMode.MultiProject, false))
{
DialogResult result = tpp.ShowDialog();
if (result == DialogResult.OK)
{
System.Console.WriteLine("Selected Team Project Collection Uri: " + tpp.SelectedTeamProjectCollection.Uri);
System.Console.WriteLine("Selected Projects:");
foreach(ProjectInfo projectInfo in tpp.SelectedProjects)
{
System.Console.WriteLine(projectInfo.Name);
}
}
}
If you don't care about the project and only want the user to be able to select a server and collection, use TeamProjectPickerMode.NoProject in the constructor.

Resources