Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Return descriptions to the interface
Message
 
 
À
23/10/2015 08:08:21
John Baird
Coatesville, Pennsylvanie, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Entity Framework
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01626353
Message ID:
01626374
Vues:
44
>>Hi everybody,
>>
>>I'm thinking what would be the best way for the following scenario.
>>
>>I have the Sales Channel table and a related table called ScSgLink, where Sg stands for sales points group and has a link to the Sales Points Groups.
>>
>>I implemented this for the GetById in that SChannels Repository:
>>
>>
>> public override SChannels GetById(object id)
>>        {
>>            var sChannel = _siriusContext.SChannels.Include("ScsgLink")            
>>             
>>             .Where(x => x.ChannelId == (Int32)id)
>>             .First();
>>
>>
>>            return sChannel;
>>        }
>>
>>That correctly returns collection of the ScSgLink objects.
>>
>>My problem is that I want to also show group description which is in another table.
>>
>>My current EditViewModel has the following:
>>
>>
>>  public int ChannelId { get; set; }
>>        
>>        [Display(Name = "descrip", ResourceType = typeof(Labels))]
>>        public string Descrip { get; set; }
>>        
>>        public string CUdf1 { get; set; }
>>        
>>        public string CUdf2 { get; set; }
>>        
>>        public bool Hidden { get; set; }
>>
>>        //public System.Collections.Generic.ICollection<Siriusware.Models.Max4Sale> Max4Sale { get; set; }
>>
>>        public System.Collections.Generic.ICollection<Siriusware.Models.ScsgLink> ScsgLink { get; set; }
>>
>>I need to somehow display the group description in the interface and here I am not sure of the good way to implement it.
>>
>>I can create another class to add description and use that class in the ICollection or I can add the GroupDescription to the ScsgLink class (as a partial class with that new property).
>>
>>The problem is that I don't know exactly how to retrieve it. Assuming I've added GroupDescription property to the ScsgLink class how should I modify the GetById method to grab it as well? It is coming from the SpGroup table (
>>
>>public int GroupNo { get; set; } // group_no (Primary key). Primary key
>>        public string Descrip { get; set; } // descrip)
>>
>>Thanks in advance.
>
>use a linq join

I was thinking also of a linq join but not exactly sure how to incorporate it in this syntax:
            var sChannel = _siriusContext.SChannels.Include("ScsgLink")            
             
             .Where(x => x.ChannelId == (Int32)id)
             .First();
I'll try something. I think I'm on the right track of thinking of adding a new GroupDescription property to that ScsgLink class. It will make the rest of the things easier.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform