Using System.Data.Linq in a Razor view

前端 未结 5 2211
名媛妹妹
名媛妹妹 2020-12-03 00:54

I may have a fundamental misunderstanding of what is going on here, but I\'m having an issue looping through a LinqToSQL class in my razor view:

Ow

5条回答
  •  爱一瞬间的悲伤
    2020-12-03 01:31

    You need to import the namespace into your view by adding @using System.Data.Linq at the top of your view. However if you want it in all your views then you need to add to the web.config in your Views folder:

      
        
        
          
            
            
            
            
            
          
        
      
    

    Although not relevent to your question you should really try to move this logic out of the view and into the controller, it will make things much easier to debug and means that your presentation is separated from your business logic.

提交回复
热议问题