唯一ID最后为空 [英] unique id last empty

查看:99
本文介绍了唯一ID最后为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用数据库中最后一个数据的调用创建了一个唯一的ID.如果数据最后为空怎么办?

I have created a unique id with the calling of the last data in the database. what if the data last empty?

public static void NewDemand(FilterDemand newDemandData)
        {
            using (WMS.DAL.WarehouseLinqDataContext dc = new WMS.DAL.WarehouseLinqDataContext())
            {
                WMS.DAL.Demand Demand = new WMS.DAL.Demand();
                DemandData DemandD = new DemandData();
                List<DemandData> listDemand = new List<DemandData>();
                var log = from de in dc.Demands
                          group de by new { de.ID_Demand } into result
                          select new
                          {
                              id1 = result.Key.ID_Demand,
                              id2 = result.Select(i => i.ID_Demand),
                              y = result.Select(i => i.Year)
                          };

                foreach (var d in log)
                {
                    DemandD.IDDemand = d.id2.Last();
                    listDemand.Add(DemandD);
                }

                string al = DemandD.IDDemand;
                int x = 0;
                string _val1 = al.Substring(1, al.Length - 5);
                x = Convert.ToInt32(_val1) + 1;
                string ff = "";
                ff = "D" + x;
                
                Demand.Month = newDemandData.FilterMonth;
                        Demand.ID_Demand = "D1";
                        Demand.GF = (float)newDemandData.FilterGF;
                        Demand.IND = (float)newDemandData.FilterIndoor;
                        Demand.Year = (int)newDemandData.FilterYear;
                        Demand.Total = Demand.GF + Demand.IND;
                        dc.Demands.InsertOnSubmit(Demand);
                        dc.SubmitChanges();
                
                }
            }

推荐答案

作为最后一步,请检查最后一行是否为空.如果是这样,请删除它.
As a final step, check to see if the last row is empty. If it is, DELETE it.


这篇关于唯一ID最后为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆