In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to use the Linq Setting field for you. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Linq Setting field storage
This article introduces the Linq Setting field, the people who have used Linq know its benefits, such as designing a table such as student information table, such as learning hobbies, personality, life experience and other fields, I believe that the previous design concept is to design three fields into three Nvarchar (8000) type fields, or some of them are designed as Text type fields, these designs are all right, but they are not very good.
Now that you have Linq, you can put all three fields in the Linq Setting field (note that the name of the field must be Setting), and the data can be stored by setting the Linq Setting field to the image type. How to use C # syntax to store it? We'll talk about it later. The disadvantage of using Setting field to store data is that when doing conditional query, using Setting as query condition is somewhat complex, and generally does not make conditional query.
Private string _ hotelDescription = string.Empty;// public string HotelDescription {get {return _ hotelDescription;} set {_ hotelDescription = value;} partial void OnLoaded () {byte [] bytes = Setting.ToArray (); CSetting setting = new CSetting (bytes); load (setting);} partial void OnValidate (System.Data.Linq.ChangeAction action) {CSetting setting = new CSetting (); save (setting); byte [] bytes = setting.ToByteArray (); Setting = new Binary (bytes) } private void save (CSetting setting) {setting.Set ("desc", _ hotelDescription);} private void load (CSetting setting) {_ hotelDescription = setting.Get ("desc", string.Empty);}
Union in Linq (recursive query, query all nodes under the parent node)
Var query = (from item1 in dc.SysOrganization
Where (item1.FatherSysOrganizationID = = orgId) & & item1.IsDel = = false
Select new SysOrganizationInfo {SysOrganizationID = item1.SysOrganizationID
Name=item1.Name,Code=item1.Code,BaseProvinceID= (int) item1.BaseProvinceID
BaseCityID= (int) item1.BaseCityID})
.Union (
From item2 in dc.SysOrganization
Join item3 in dc.SysOrganization
On item2.FatherSysOrganizationID equals item3.SysOrganizationID
Where (item2.SysOrganizationID = = orgId) & & item2.IsDel = = false
Select new SysOrganizationInfo {SysOrganizationID = item2.SysOrganizationID
Name = item2.Name, Code = item2.Code, BaseProvinceID = (int) item2.BaseProvinceID
BaseCityID = (int) item2.BaseCityID})
The combination of subqueries of Join and Company in Linq
Var roles = from aa in (
From an in dc.SysOrganizationRoleUser
Join b in dc.SysOrganizationRole on a.SysRoleID equals b.SysRoleID
Join c in dc.SysOrganizationRoleFunctionItem on b.SysRoleID equals c.SysRoleID
Join d in dc.SysFunctionItem on c.SysFunctionItemID equals d.SysFunctionItemID
Join d2 in dc.SysFunctionItem on c.SysFunctionItemID equals d2.SysFunctionItemID
Where a.SysUserID = = userID
Select d)
From bb in dc.SysFunctionItem
Where aa.SysFunctionItemID = = bb.SysFunctionItemID | |
Aa.FatherFunctionItemID = = bb.SysFunctionItemID
Select bb
The left join query in Linq uses the DefaultIfEmpty () syntax
Var svcUser = from an in hdc.SysServiceCenterUser
Join b in hdc.SysServiceCenter on a.SysServiceCenterID equals b.SysServiceCenterID
Join c in hdc.SysServicePositionUser on a.SysUserID equals c.SysUserID into pous
From c in pous.DefaultIfEmpty ()
Join d in hdc.SysServiceCenterPosition on c.SysServicePositionID
Equals d.SysServicePositionID into po
From d in po.DefaultIfEmpty ()
Where (_ SysServiceCenterID = = 0? True: a.SysServiceCenterID = = _ SysServiceCenterID)
& & (_ SysServicePositionID = = 0? True: (from w in hdc.SysServicePositionUser where
W.SysServicePositionID = = _ SysServicePositionID select w.SysUserID) .contains (a.SysUserID))
& & (_ Name = = null | | _ Name.Trim () = = ""? True: a.FullName.Contains (_ Name))
& & (_ Code = = null | | _ Code.Trim () = = ""? True: a.Code = = _ Code)
Select new Svc
{
_ SysUserID = (a.SysUserID = = null? 0: a.SysUserID)
_ SysServiceCenterID= (a.SysServiceCenterID==null?0: (int) a.SysServiceCenterID)
/ / _ SysServicePositionID = (int) c.SysServicePositionID
_ SvcName = b.Name
/ / _ PositionName = d.Name
_ LoginName = a.LoginName
_ FullName = a.FullName
_ Code= (a.Code==null? "": a.Code)
}
This is the end of the article on "how to use the Linq Setting field". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.