I am trying to add description when attaching a file and I use MVVM Model. I create a commandHolder and from there create a command and I unable to convert a Lazy<View> to Lazy<RelayCommand> I request you to please help me in this.
this.fileAttachmentDescriptionCommandHolder = new Lazy<FileAttachmentDescriptionView>(() => new FileAttachmentDescriptionView { DataContext = this });
this.fileAttachmentDescriptionViewHolder = new Lazy<RelayCommand>(this.CreateFileAttachmentDescriptionCommand);
I get the error:
Error CS0029 Cannot implicitly convert type 'System.Lazy
Path.RelayCommand' to 'System.Lazy path.View'
I think you're doing it backwards, as stated in the comment by mechanic.
this.fileAttachmentDescriptionCommandHolder =
new Lazy<RelayCommand>(this.CreateFileAttachmentDescriptionCommand);
this.fileAttachmentDescriptionViewHolder =
new Lazy<FileAttachmentDescriptionView>(
() => new FileAttachmentDescriptionView { DataContext = this });
Related
error: Severity Code Description Project File Line Suppression State
Error CS0029 Cannot implicitly convert type 'Xamarin.Essentials.ShareFile[]' to 'System.Collections.Generic.List<Xamarin.Essentials.ShareFile>'
code should work bc i got it from microsoft docs: ref: Microsoft docs
await Share.RequestAsync(new ShareMultipleFilesRequest
{
Files = new ShareFile[] { new ShareFile(filepath1), new ShareFile(filepath2) }
});
if ShareMultipleFilesRequest.Files is a list you need to provide a list:
await Share.RequestAsync(new ShareMultipleFilesRequest
{
Files = new List<ShareFile> { new ShareFile(filepath1), new ShareFile(filepath2) }
});
Is there a way to prevent a $type property being added when I save my dynamic type values?
When I save this:
new Activity {
Name = "FormFieldDeleted",
Body = new {
MyDeletedFormField(),
MyCompleteForm()
}
}
I get this
<>f__AnonymousType1`2[[MyProject.Domains.Forms.Models.FormField, MyProject.Domains.Forms],[MyProject.Domains.Forms.Entities.FormRegistration, MyProject.Domains.Forms]], MyProject.Api.Forms
But when I try to fetch this saved entity, it crashes with the exception below. I know it's missing a project reference, but I really don't want to add that reference (I don't want to reference an API from a console app). It's better for me to just prevent the $type property.
/usr/local/share/dotnet/dotnet path/MyProject/MyProject/src/MyProject.Tasks.MapActivities/bin/Debug/netcoreapp3.1/MyProject.Tasks.MapActivities.dll
Unhandled exception. System.InvalidOperationException: Could not convert document 31317d58-db9e-4f60-8dee-b8593f3e06c0 to entity of type MyProject.Domains.Core.Entities.Activity
---> Newtonsoft.Json.JsonSerializationException: Error resolving type specified in JSON '<>f__AnonymousType1`2[[MyProject.Domains.Forms.Models.FormField, MyProject.Domains.Forms],[MyProject.Domains.Forms.Entities.FormRegistration, MyProject.Domains.Forms]], MyProject.Api.Forms'. Path 'Body.$type'.
---> Newtonsoft.Json.JsonSerializationException: Could not load assembly 'MyProject.Api.Forms'
....
Yes, there is a way.
You can customize the way serialization works using the following code:
store.Conventions.CustomizeJsonSerializer = serializer =>
{
serializer.TypeNameHandling = Newtonsoft.Json.TypeNameHandling.None;
};
As an example, take a look at the code here : https://dotnetfiddle.net/voJ7US
If you execute the code at the dotnetfiddle, you can see the results here: http://live-test.ravendb.net/studio/index.html#databases/documents?collection=Activities&database=UniqueTestDB
For RavenDB 5 and higher it changed a bit.
var store = DocumentStore
{
Urls = new[] { "your-endpoint" },
Conventions = new DocumentConventions
{
Serialization = new NewtonsoftJsonSerializationConventions
{
CustomizeJsonSerializer = serializer =>
{
serializer.TypeNameHandling = Newtonsoft.Json.TypeNameHandling.None;
}
}
}
}.Initialize();
See https://ravendb.net/docs/article-page/5.0/file-header/migration/client-api/conventions for more information.
public ISearchResponse<object> GetById(string id) {
var uri = new Uri("<myendpoint>");
var settings = new ConnectionSettings(uri).DefaultIndex("useraction-*").PrettyJson().DisableDirectStreaming(); //or try _all
var client = new ElasticClient(settings);
var search = new SearchRequest<object>
{
Query = new TermQuery
{
Field = "field",
Value = "example"
}
};
var response = client.Search<object>(search);
return response;
}
I'm having trouble getting NEST to work. When I try to call the query defined above, I get the following error:
System.Exception: If you use a custom contract resolver be sure to subclass from ElasticResolver
at Nest.JsonExtensions.GetConnectionSettings(JsonSerializer serializer) in C:\Users\russ\source\elasticsearch-net-master\src\Nest\CommonAbstractions\Extensions\JsonExtensions.cs
I've searched the internet for mention of this and can't seem to find anything other than the source code. I've pretty much followed the documentation exactly so I don't know what to change.
Does anyone out there know what this error is trying to tell me? I feel like it's an error behind the scenes that I don't have control over.
I'm happy to answer additional questions if people need more info.
Thanks.
Also I don't know where that path is coming from in the exception because I have no user "russ"
I want to create issue. Wsdl can be found here. I have created client using Visual Studio and c#.
I can login
JiraSoapServiceService jiraSoapService = new JiraSoapServiceService();
jiraSoapService.login(jiraLogin, jiraPassword);
I can get information
jiraSoapService.getIssue(auth, key);
but I can not create an issue
RemoteIssue issue = new RemoteIssue();
issue.setSummary(SUMMARY_NAME);
as it gives me JIRA_API.box.RemoteIssue does not contain a definition for setSummary. Whats is wrong?
RemoteIssue issue = new RemoteIssue();
issue.project = "[NAME]";
issue.key="[KEY]";
issue.type = "3";
RemoteComponent component = new RemoteComponent();
component.name = "[COMPONENT_NAME]";
issue.components = (new RemoteComponent[] { component });
issue.summary = "[SUMMARY]";
issue.assignee = "[ASSIGNEE]";
RemoteIssue returnedIssue = jiraSoapService.createIssue(token, issue);
I'm writing code that pulls from a db and populates the information as an activity, I'm successfully able to add fields from db to description and subject field, but I cant seem to get it to link to an account?
Here is what i have tried;
foreach (var phoneNumber in phoneNumbers)
{
var potentialMatches = _xrm.AccountSet.Where(account => account.Address1_Telephone2.Equals(phoneNumbers)).ToList();
if (potentialMatches.Count > 0)
{
var accountMatch = potentialMatches.First();
var actualCRMAccount = (Account) _xrm.Retrieve("Account", accountMatch.Id, new Microsoft.Xrm.Sdk.Query.ColumnSet(true));
if (actualCRMAccount != null)
{
//Is this correct way?
new ActivityParty()
{
PartyId = new EntityReference(Account.EntityLogicalName, actualCRMAccount.Id)
};
activityParties.Add(new ActivityParty() {Id = actualCRMAccount.Id});
}
}
}
//RegardingObjectId not working
//RegardingObjectId = new EntityReference(Account.EntityLogicalName, recordRow.Cells[0].Value.ToString);
newMsg.To = activityParties;
newMsg.Description = recordRow.Cells[0].Value.ToString();
newMsg.Subject = recordRow.Cells[2].Value.ToString();
_xrm.Create(newMsg);
EDIT 1:
When i run it now im getting this warning
An unhandled exception of type 'System.ServiceModel.FaultException`1' occurred in Microsoft.Xrm.Sdk.dll .
Additional information: The entity with a name = 'Account' was not found in the MetadataCache.
This is the piece of code where it throws the warning
var actualCRMAccount = (Account)_xrm.Retrieve("Account", accountMatch.Id, new Microsoft.Xrm.Sdk.Query.ColumnSet(true));
Why would this be?
Edit 2:
I replaced Account with account, see below.
var actualCRMAccount = (Account)_xrm.Retrieve("account", accountMatch.Id, new Microsoft.Xrm.Sdk.Query.ColumnSet(true));
Edit 3:
Im now trying to do it for leads. but when i add this bit of code.
newMsg.RegardingObjectId = activityParties;
I get this error.
Cannot implicitly convert type 'System.Collections.Generic.List' to 'Microsoft.Xrm.Client.CrmEntityReference'
How can assign a value to RegardingObjectId.
Thanks for everyone's help.
The problem is that you´re adding the account via:
new ActivityParty() { Id = actualCRMAccount.Id }
To define a new ActivityParty you must set the PartyId property which is an entity reference for the chosen Type.
new ActivityParty() { PartyId = new EntityReference(Account.EntityLogicalName,actualCRMAccount.Id) }
should work.
There is a typo in the following line:
var potentialMatches = _xrm.AccountSet.Where(account => account.Address1_Telephone2.Equals(phoneNumbers)).ToList();
.Equals(phoneNumbers) should be: .Equals(phoneNumber)
Then replace the code after the retrieval of the account record with this:
var actualCRMAccount = (Account)_xrm.Retrieve("Account", accountMatch.Id, new Microsoft.Xrm.Sdk.Query.ColumnSet(true));
if (actualCRMAccount != null)
{
activityParties.Add(new ActivityParty { PartyId = actualCRMAccount.ToEntityReference() });
}