Get comma separated values from a table
Get comma separated values from a table:
I have two tables Customer and allocation. Customer and
allocation.
in allocation table the customer_id is the foreign_key. in
allocation table same customer_id having different users.I want to select the
distinct customer with comma separated users
var tablecustomer = _customerRepository.GetAll().Where(x
=> x.IsActive);
var
tableallocation = _allocationRepository.GetAll().Where(x => x.IsActive);
var
userPrivilege = _userPrivilegeRepository.GetAll().Where(x => x.IsActive ==
true && x.DisableView == true
&&
x.UserId == LoginUser_ID);
var Customers =
(from c in tablecustomer
join ca in tableallocation on c.ID equals ca.Customer_ID
group ca.UserID by ca.CustomerID into grp
from res in grp.DefaultIfEmpty()
join up in userPrivilege on
new
{
Key1
= LoginUser_ID,
Key2
= c.ID
}
equals
new
{
Key1
= up.UserId,
Key2
= up.Customer_Id
}
Into
usrPrivlg
From up in
usrPrivlg.DefaultIfEmpty()
Select new CustomerWithUserViewModel
{
ID = c.ID,
Name=
string.Join(",", res.UserID == 0 ? 0 : res.UserID),
});
Old Post :
- Asp.net-user-control-basics
- Introduction-of-asp.net-server-control.
- how-to-check-image-size-before.
- how-to-edit-list-view-template
- how-to-use-asp-list view-control-in.
- how-to-make-effective-frq-page-in-web
- how-to-use-repeater-control-in-asp.net.
- how-to-add-reference-of-dll-file-in.Asp.net
- how-to-use-how-to-use-captcha-in-asp net
- how-to-use-how-to-use-captcha-in-asp.net.html
- How-to-use-regular-expression-in-asp.net.html
- Using jQuery change Background color of DIV
- JQuery Change Div Background Color Randomly
- JQuery Change Div Background Color Randomly
- C# Variables,How to declare in C#:
- C# language Program Structure
- What keyword,How many keywords in C#
KLIK HERE VISIT NOW AND GET YOUR LUCKY ! ! !
ReplyDeleteBONUS LEBARAN JOIN NOW AND GET BONUS ! ! !
KLIK PROMO MEMBER BARU BONUS FREEBET
KLIK PROMO BONUS EXTRA 100% BOLA PARLAY BONUS 5JuTa SETIAP MINGGUNYA