|' cannot be applied to operands of type 'string' and 'string' ( how i can fix this )

问题描述 投票:0回答:1

This Is Windows form im newbe and i have not ton of skill but i understand

i have 5 table


layer = layerID int , layerName string ( layerID = PK )

Gor = LayerID int , GroID int , GroNnumber string ( GroID = PK and LayerID = FK )

Gru = GruID int , GroID int , GruNumber string (GruID = PK and GorID = FK )

Das = GruID int , DasID int, DasNumber string (DasID = PK and GruID = FK )

Grop = GropID int , DasID int , GropNumber string (GropID = PD and DasID = FK )

all this 5 table relation ( PK - FK )

i use Join for read all data from this 5 tableand my code work as well and i can see all my data from all 4 table inside my datagridview

this is my code

using (UnitOfWork db = new UnitOfWork())
{
DGVCharts.AutoGenerateColumns = false;

    var result = from layer in db.LayerRepository.Get()
        join gor in db.GorRepository.Get() on layer.LayerID equals gor.LayerID
        join gru in db.GruRepository.Get() on gor.GorID equals gru.GorID
        join das in db.DasRepository.Get() on gru.GruID equals das.GruID
        join grop in db.GropRepository.Get() on das.DastehID equals grop.DastehID


    select new
    {
        layer.LayerID,
        layer.LayerName,
        gor.GorID,
        gor.GorNumber,
        gru.GruID,
        gru.GruNumber,
        das.DasID,
        das.DasNumber,
        grop.GropID,
        grop.GropNumber,


        };
        DGVCharts.DataSource = result.ToList();

       }

     }

'''

this is my last table

Position = PositionID int, PositionCharts string, PositionName string

PositionCharts Data = ( GruNumber Data,DasNumber Data, GroNumber Data )

Data Something like this

GruNumber , DasNumber , GropNumber

Gru01, Das01, Grop01

Gru02, Das02, Grop02

FreeGru01, FreeDas01, FreeGrop01


PositionCharts : PositionName

FreeGru01: Master

FreeDas01: Member

FreeGrop01: Boss


i use this code for join this data if ( GruNumber or DasNumber or GropNumber = positioncharts )then i see PositionName in my datagridview too

i change my code to this code

'''

using (UnitOfWork db = new UnitOfWork())
{
DGVCharts.AutoGenerateColumns = false;

    var result = from layer in db.LayerRepository.Get()
        join gor in db.GorRepository.Get() on layer.LayerID equals gor.LayerID
        join gru in db.GruRepository.Get() on gor.GorID equals gru.GorID
        join das in db.DasRepository.Get() on gru.GruID equals das.GruID
        join grop in db.GropRepository.Get() on das.DastehID equals grop.DastehID
        join position in db.PositionRepository.Get() on gru.GruNumber || das.DastehNumber || grop.GroupNumber equals position.PositionCharts

    select new
    {
        layer.LayerID,
        layer.LayerName,
        gor.GorID,
        gor.GorNumber,
        gru.GruID,
        gru.GruNumber,
        das.DasID,
        das.DasNumber,
        grop.GropID,
        grop.GropNumber,
        position.PositionID,
        position.PositionName
};
DGVCharts.DataSource = result.ToList();

}

}

'''but after i use this code i receive this error

operator '

c# sql linq join datagridview
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.