xyrile
xyrile
CC#
Created by xyrile on 10/17/2024 in #help
✅ Can someone check if my authorization or authentication is good or bad
10 replies
CC#
Created by xyrile on 5/28/2024 in #help
AspNetCore.Reporting.LocalReport caching issue export excel
No description
5 replies
CC#
Created by xyrile on 4/13/2024 in #help
EF Core how to add two same object in 1 model
public int UserId { get; set; }
[ForeignKey("UserId")]
public AccountModel Account { get; set; } = new();
public int MarkAsPaidById { get; set; }
[ForeignKey("MarkAsPaidById")]
public AccountModel MarkAsPaidByAccount { get; set; } = new();
public int UserId { get; set; }
[ForeignKey("UserId")]
public AccountModel Account { get; set; } = new();
public int MarkAsPaidById { get; set; }
[ForeignKey("MarkAsPaidById")]
public AccountModel MarkAsPaidByAccount { get; set; } = new();
[Table("Accounts")]
[PrimaryKey("UserId")]
public class AccountModel
{
public int UserId { get; set; }
public string Username { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
}
[Table("Accounts")]
[PrimaryKey("UserId")]
public class AccountModel
{
public int UserId { get; set; }
public string Username { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
}
4 replies
CC#
Created by xyrile on 3/26/2024 in #help
Why does using `await` EF core execute command twice
I am using Blazor server app and add EF Core
public class UserAccountService(AppDBContext context) : ControllerBase, IUserAccountService
{
private readonly AppDBContext _context = context;
[HttpGet]
public async Task<IEnumerable<UserAccountModel>> GetAccounts()
{
return await _context.Accounts.ToListAsync();
}
}
public class UserAccountService(AppDBContext context) : ControllerBase, IUserAccountService
{
private readonly AppDBContext _context = context;
[HttpGet]
public async Task<IEnumerable<UserAccountModel>> GetAccounts()
{
return await _context.Accounts.ToListAsync();
}
}
Dependency
builder.Services.AddScoped<IUserAccountService, UserAccountService>();
builder.Services.AddScoped<IUserAccountService, UserAccountService>();
Here is the code where query executes twice
protected override async Task OnInitializedAsync()
{
var response = await UserAccountService.GetAccounts();
if (response != null)
{
accounts = response.ToList();
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(accounts, Newtonsoft.Json.Formatting.Indented));
}
else
{

}

}
protected override async Task OnInitializedAsync()
{
var response = await UserAccountService.GetAccounts();
if (response != null)
{
accounts = response.ToList();
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(accounts, Newtonsoft.Json.Formatting.Indented));
}
else
{

}

}
14 replies
CC#
Created by xyrile on 3/5/2024 in #help
.NET 8 error when using ASP.NET AspNetCore.Reporting.LocalReport
var result = localReport.Execute(AspNetCore.Reporting.RenderType.ExcelOpenXml, 1, param, ""); Error message
Inner Exception 1:
DefinitionInvalidException: The definition of the report 'C:\FGCI Projects\FGCI Report Server\fgcireportserver\fgcireportservercore\fgcireportservercore\bin\Debug\net8.0\Reports\AccountingManagementReportFormats\voucherroutereportexcel.rdlc' is invalid.
An unexpected error occurred in Report Processing.
Compiler executable file C:\WINDOWS\Microsoft.NET\Framework64\v8.0.1\vbc.exe cannot be found.

Inner Exception 2:
ReportProcessingException: An unexpected error occurred in Report Processing.
Compiler executable file C:\WINDOWS\Microsoft.NET\Framework64\v8.0.1\vbc.exe cannot be found.

Inner Exception 3:
InvalidOperationException: Compiler executable file C:\WINDOWS\Microsoft.NET\Framework64\v8.0.1\vbc.exe cannot be found.
Inner Exception 1:
DefinitionInvalidException: The definition of the report 'C:\FGCI Projects\FGCI Report Server\fgcireportserver\fgcireportservercore\fgcireportservercore\bin\Debug\net8.0\Reports\AccountingManagementReportFormats\voucherroutereportexcel.rdlc' is invalid.
An unexpected error occurred in Report Processing.
Compiler executable file C:\WINDOWS\Microsoft.NET\Framework64\v8.0.1\vbc.exe cannot be found.

Inner Exception 2:
ReportProcessingException: An unexpected error occurred in Report Processing.
Compiler executable file C:\WINDOWS\Microsoft.NET\Framework64\v8.0.1\vbc.exe cannot be found.

Inner Exception 3:
InvalidOperationException: Compiler executable file C:\WINDOWS\Microsoft.NET\Framework64\v8.0.1\vbc.exe cannot be found.
1 replies
CC#
Created by xyrile on 12/14/2022 in #help
❔ Binary tree pre order
How to make a loop out of this ?
Tree tree = new Tree();
tree.root = new Node(1);
tree.root.left = new Node(12);
tree.root.right = new Node(9);
tree.root.left.left = new Node(5);
tree.root.left.right = new Node(6);
Tree tree = new Tree();
tree.root = new Node(1);
tree.root.left = new Node(12);
tree.root.right = new Node(9);
tree.root.left.left = new Node(5);
tree.root.left.right = new Node(6);
4 replies
CC#
Created by xyrile on 12/6/2022 in #help
Iterator (Argument 1 cannot convert from 'Coding.Exercise.Nodechar[]' to 'char*' Compilation failed)
public class Node<T>
{
public T value;
public Node<T> left, right, parent;

public Node(T value)
{
this.value = value;
}

public Node(T value, Node<T> left, Node<T> right)
{
this.value = value;
this.left = left;
this.right = right;

left.parent = right.parent = this;
}

public IEnumerable<Node<T>> PreOrder
{
get
{
return new PreOrderIterator<T>(this);
}
}
}
public class PreOrderIterator<T> : IEnumerable<Node<T>>
{
private Stack<Node<T>> stack = new Stack<Node<T>>();
public PreOrderIterator(Node<T> root)
{
stack.Push(root);
}
public IEnumerator<Node<T>> GetEnumerator()
{
foreach (Node<T> node in stack)
{
yield return node;
}
}

IEnumerator IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
}
}
public class Node<T>
{
public T value;
public Node<T> left, right, parent;

public Node(T value)
{
this.value = value;
}

public Node(T value, Node<T> left, Node<T> right)
{
this.value = value;
this.left = left;
this.right = right;

left.parent = right.parent = this;
}

public IEnumerable<Node<T>> PreOrder
{
get
{
return new PreOrderIterator<T>(this);
}
}
}
public class PreOrderIterator<T> : IEnumerable<Node<T>>
{
private Stack<Node<T>> stack = new Stack<Node<T>>();
public PreOrderIterator(Node<T> root)
{
stack.Push(root);
}
public IEnumerator<Node<T>> GetEnumerator()
{
foreach (Node<T> node in stack)
{
yield return node;
}
}

IEnumerator IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
}
}
Can someone help me with this ? this is preorder Traverse
12 replies
CC#
Created by xyrile on 12/2/2022 in #help
❔ Design pattern Iterator
So I was working with Node<T> in PreOrder Traversal when i try to test it gives me an error message saying Something is wrong in our systems, your code took too long to execute. Here's my code
public class Node<T>
{
public T value;
public Node<T> left, right, parent;

public Node(T value)
{
this.value = value;
}

public Node(T value, Node<T> left, Node<T> right)
{
this.value = value;
this.left = left;
this.right = right;

left.parent = right.parent = this;
}

public IEnumerable<T> PreOrder
{
get
{
return new PreOrderIterator<T>(this);
}
}
}
public class PreOrderIterator<T> : IEnumerable<T>
{
private Stack<Node<T>> stack = new Stack<Node<T>>();
public PreOrderIterator(Node<T> root)
{
stack.Push(root);
}
public IEnumerator<T> GetEnumerator()
{
return GetEnumerator();
}

IEnumerator IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
}
}
public class Node<T>
{
public T value;
public Node<T> left, right, parent;

public Node(T value)
{
this.value = value;
}

public Node(T value, Node<T> left, Node<T> right)
{
this.value = value;
this.left = left;
this.right = right;

left.parent = right.parent = this;
}

public IEnumerable<T> PreOrder
{
get
{
return new PreOrderIterator<T>(this);
}
}
}
public class PreOrderIterator<T> : IEnumerable<T>
{
private Stack<Node<T>> stack = new Stack<Node<T>>();
public PreOrderIterator(Node<T> root)
{
stack.Push(root);
}
public IEnumerator<T> GetEnumerator()
{
return GetEnumerator();
}

IEnumerator IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
}
}
6 replies
CC#
Created by xyrile on 12/2/2022 in #help
Design pattern
So i was stuck in composite coding with c# I just cant get the ouput maybe someone know about this
namespace Coding.Exercise
{
public interface IValueContainer
{

}

public class SingleValue : IValueContainer
{
public int Value;
}

public class ManyValues : List<int>, IValueContainer
{

}

public static class ExtensionMethods
{
public static int Sum(this List<IValueContainer> containers)
{
int result = 0;
foreach (var c in containers)
foreach (var i in c)
result += i;
return result;
}
}
}
namespace Coding.Exercise
{
public interface IValueContainer
{

}

public class SingleValue : IValueContainer
{
public int Value;
}

public class ManyValues : List<int>, IValueContainer
{

}

public static class ExtensionMethods
{
public static int Sum(this List<IValueContainer> containers)
{
int result = 0;
foreach (var c in containers)
foreach (var i in c)
result += i;
return result;
}
}
}
1 replies